fix: always return hasNextPage boolean to frontend

- removes dependency on uiDefaults setting
This commit is contained in:
Christoph Kluge 2025-03-18 18:01:37 +01:00
parent 25aaf55b93
commit c53f5eb144

View File

@ -354,30 +354,28 @@ func (r *queryResolver) Jobs(ctx context.Context, filter []*model.JobFilter, pag
return nil, err return nil, err
} }
if !config.Keys.UiDefaults["job_list_usePaging"].(bool) { // Note: Even if App-Default 'config.Keys.UiDefaults["job_list_usePaging"]' is set, always return hasNextPage boolean.
hasNextPage := false // Users can decide in frontend to use continuous scroll, even if app-default is paging!
// page.Page += 1 : Simple, but expensive /*
// Example Page 4 @ 10 IpP : Does item 41 exist? Example Page 4 @ 10 IpP : Does item 41 exist?
// Minimal Page 41 @ 1 IpP : If len(result) is 1, Page 5 @ 10 IpP exists. Minimal Page 41 @ 1 IpP : If len(result) is 1, Page 5 @ 10 IpP exists.
*/
nextPage := &model.PageRequest{ nextPage := &model.PageRequest{
ItemsPerPage: 1, ItemsPerPage: 1,
Page: ((page.Page * page.ItemsPerPage) + 1), Page: ((page.Page * page.ItemsPerPage) + 1),
} }
nextJobs, err := r.Repo.QueryJobs(ctx, filter, nextPage, order) nextJobs, err := r.Repo.QueryJobs(ctx, filter, nextPage, order)
if err != nil { if err != nil {
log.Warn("Error while querying next jobs") log.Warn("Error while querying next jobs")
return nil, err return nil, err
} }
hasNextPage := false
if len(nextJobs) == 1 { if len(nextJobs) == 1 {
hasNextPage = true hasNextPage = true
} }
return &model.JobResultList{Items: jobs, Count: &count, HasNextPage: &hasNextPage}, nil return &model.JobResultList{Items: jobs, Count: &count, HasNextPage: &hasNextPage}, nil
} else {
return &model.JobResultList{Items: jobs, Count: &count}, nil
}
} }
// JobsStatistics is the resolver for the jobsStatistics field. // JobsStatistics is the resolver for the jobsStatistics field.