Handle large and all entity queries (#3544)

* Remove upper page size limit
* Batch GetMany function
* Remove upper query limit from UI
This commit is contained in:
WithoutPants
2023-03-16 09:08:21 +11:00
committed by GitHub
parent ac67d640db
commit 58852f86fe
10 changed files with 130 additions and 75 deletions

View File

@@ -260,17 +260,23 @@ func (qb *ImageStore) Find(ctx context.Context, id int) (*models.Image, error) {
}
func (qb *ImageStore) FindMany(ctx context.Context, ids []int) ([]*models.Image, error) {
q := qb.selectDataset().Prepared(true).Where(qb.table().Col(idColumn).In(ids))
unsorted, err := qb.getMany(ctx, q)
if err != nil {
return nil, err
}
images := make([]*models.Image, len(ids))
for _, s := range unsorted {
i := intslice.IntIndex(ids, s.ID)
images[i] = s
if err := batchExec(ids, defaultBatchSize, func(batch []int) error {
q := qb.selectDataset().Prepared(true).Where(qb.table().Col(idColumn).In(batch))
unsorted, err := qb.getMany(ctx, q)
if err != nil {
return err
}
for _, s := range unsorted {
i := intslice.IntIndex(ids, s.ID)
images[i] = s
}
return nil
}); err != nil {
return nil, err
}
for i := range images {