mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-28 07:53:33 -06:00
[bugfix] use a much shorter refresh limit for statuses with polls (#2453)
* specifically use a much shorter refresh limit for statuses with polls * allow specifying whether status must be upToDate in calls to Get(Visible)?TargetStatusBy_(), limit force refresh to 5 minute cooldown * remove the PollID check from statusUpToDate() * remove unnecessary force flag checks * remove unused field * check refresh status error * use argument name 'refresh' instead of 'upToDate' to better fit with the codebase * add statuses_poll_id_idx * remove the definitely-not copy-pasted comment i accidentally typed out in full * only synchronously refresh if the refresh flag is provided, otherwise do async * fix wrong force value being provided for async --------- Co-authored-by: tobi <tobi.smethurst@protonmail.com>
This commit is contained in:
parent
d0bb8f0973
commit
f4fcffc8b5
17 changed files with 207 additions and 98 deletions
|
|
@ -50,20 +50,6 @@ func (p *pollDB) GetPollByID(ctx context.Context, id string) (*gtsmodel.Poll, er
|
|||
)
|
||||
}
|
||||
|
||||
func (p *pollDB) GetPollByStatusID(ctx context.Context, statusID string) (*gtsmodel.Poll, error) {
|
||||
return p.getPoll(
|
||||
ctx,
|
||||
"StatusID",
|
||||
func(poll *gtsmodel.Poll) error {
|
||||
return p.db.NewSelect().
|
||||
Model(poll).
|
||||
Where("? = ?", bun.Ident("poll.status_id"), statusID).
|
||||
Scan(ctx)
|
||||
},
|
||||
statusID,
|
||||
)
|
||||
}
|
||||
|
||||
func (p *pollDB) getPoll(ctx context.Context, lookup string, dbQuery func(*gtsmodel.Poll) error, keyParts ...any) (*gtsmodel.Poll, error) {
|
||||
// Fetch poll from database cache with loader callback
|
||||
poll, err := p.state.Caches.GTS.Poll().Load(lookup, func() (*gtsmodel.Poll, error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue