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