mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-10-31 22:40:01 +00:00
[chore] Don't try to select zero uncached filters (#3266)
This commit is contained in:
parent
25a815a8a4
commit
0560c5ce89
1 changed files with 12 additions and 5 deletions
|
@ -82,16 +82,23 @@ func (f *filterDB) GetFiltersForAccountID(ctx context.Context, accountID string)
|
||||||
// Get each filter by ID from the cache or DB.
|
// Get each filter by ID from the cache or DB.
|
||||||
filters, err := f.state.Caches.DB.Filter.LoadIDs("ID",
|
filters, err := f.state.Caches.DB.Filter.LoadIDs("ID",
|
||||||
filterIDs,
|
filterIDs,
|
||||||
func(uncachedFilterIDs []string) ([]*gtsmodel.Filter, error) {
|
func(uncached []string) ([]*gtsmodel.Filter, error) {
|
||||||
uncachedFilters := make([]*gtsmodel.Filter, 0, len(uncachedFilterIDs))
|
// Avoid querying
|
||||||
|
// if none uncached.
|
||||||
|
count := len(uncached)
|
||||||
|
if count == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
filters := make([]*gtsmodel.Filter, 0, count)
|
||||||
if err := f.db.
|
if err := f.db.
|
||||||
NewSelect().
|
NewSelect().
|
||||||
Model(&uncachedFilters).
|
Model(&filters).
|
||||||
Where("? IN (?)", bun.Ident("id"), bun.In(uncachedFilterIDs)).
|
Where("? IN (?)", bun.Ident("id"), bun.In(uncached)).
|
||||||
Scan(ctx); err != nil {
|
Scan(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return uncachedFilters, nil
|
return filters, nil
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue