mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-25 12:59:06 +01:00
fix: make hasnextpage optional parameter, use only if inf scroll configured
This commit is contained in:
parent
b9b452f043
commit
0dee5073c6
@ -278,7 +278,7 @@ type JobResultList {
|
|||||||
offset: Int
|
offset: Int
|
||||||
limit: Int
|
limit: Int
|
||||||
count: Int
|
count: Int
|
||||||
hasNextPage: Boolean!
|
hasNextPage: Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
type JobLinkResultList {
|
type JobLinkResultList {
|
||||||
|
@ -1995,7 +1995,7 @@ type JobResultList {
|
|||||||
offset: Int
|
offset: Int
|
||||||
limit: Int
|
limit: Int
|
||||||
count: Int
|
count: Int
|
||||||
hasNextPage: Boolean!
|
hasNextPage: Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
type JobLinkResultList {
|
type JobLinkResultList {
|
||||||
@ -5251,14 +5251,11 @@ func (ec *executionContext) _JobResultList_hasNextPage(ctx context.Context, fiel
|
|||||||
return graphql.Null
|
return graphql.Null
|
||||||
}
|
}
|
||||||
if resTmp == nil {
|
if resTmp == nil {
|
||||||
if !graphql.HasFieldError(ctx, fc) {
|
|
||||||
ec.Errorf(ctx, "must not be null")
|
|
||||||
}
|
|
||||||
return graphql.Null
|
return graphql.Null
|
||||||
}
|
}
|
||||||
res := resTmp.(bool)
|
res := resTmp.(*bool)
|
||||||
fc.Result = res
|
fc.Result = res
|
||||||
return ec.marshalNBoolean2bool(ctx, field.Selections, res)
|
return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) fieldContext_JobResultList_hasNextPage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
func (ec *executionContext) fieldContext_JobResultList_hasNextPage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||||
@ -13464,9 +13461,6 @@ func (ec *executionContext) _JobResultList(ctx context.Context, sel ast.Selectio
|
|||||||
out.Values[i] = ec._JobResultList_count(ctx, field, obj)
|
out.Values[i] = ec._JobResultList_count(ctx, field, obj)
|
||||||
case "hasNextPage":
|
case "hasNextPage":
|
||||||
out.Values[i] = ec._JobResultList_hasNextPage(ctx, field, obj)
|
out.Values[i] = ec._JobResultList_hasNextPage(ctx, field, obj)
|
||||||
if out.Values[i] == graphql.Null {
|
|
||||||
out.Invalids++
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
panic("unknown field " + strconv.Quote(field.Name))
|
panic("unknown field " + strconv.Quote(field.Name))
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ type JobResultList struct {
|
|||||||
Offset *int `json:"offset,omitempty"`
|
Offset *int `json:"offset,omitempty"`
|
||||||
Limit *int `json:"limit,omitempty"`
|
Limit *int `json:"limit,omitempty"`
|
||||||
Count *int `json:"count,omitempty"`
|
Count *int `json:"count,omitempty"`
|
||||||
HasNextPage bool `json:"hasNextPage"`
|
HasNextPage *bool `json:"hasNextPage,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type JobsStatistics struct {
|
type JobsStatistics struct {
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/ClusterCockpit/cc-backend/internal/config"
|
||||||
"github.com/ClusterCockpit/cc-backend/internal/graph/generated"
|
"github.com/ClusterCockpit/cc-backend/internal/graph/generated"
|
||||||
"github.com/ClusterCockpit/cc-backend/internal/graph/model"
|
"github.com/ClusterCockpit/cc-backend/internal/graph/model"
|
||||||
"github.com/ClusterCockpit/cc-backend/internal/metricdata"
|
"github.com/ClusterCockpit/cc-backend/internal/metricdata"
|
||||||
@ -234,26 +235,29 @@ func (r *queryResolver) Jobs(ctx context.Context, filter []*model.JobFilter, pag
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
hasNextPage := false
|
|
||||||
nextPage := page
|
|
||||||
nextPage.Page += 1
|
|
||||||
|
|
||||||
nextJobs, err := r.Repo.QueryJobs(ctx, filter, nextPage, order)
|
|
||||||
if err != nil {
|
|
||||||
log.Warn("Error while querying next jobs")
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if len(nextJobs) > 0 {
|
|
||||||
hasNextPage = true
|
|
||||||
}
|
|
||||||
|
|
||||||
count, err := r.Repo.CountJobs(ctx, filter)
|
count, err := r.Repo.CountJobs(ctx, filter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("Error while counting jobs")
|
log.Warn("Error while counting jobs")
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &model.JobResultList{Items: jobs, Count: &count, HasNextPage: hasNextPage}, nil
|
if !config.Keys.UiDefaults["job_list_usePaging"].(bool) {
|
||||||
|
hasNextPage := false
|
||||||
|
page.Page += 1
|
||||||
|
|
||||||
|
nextJobs, err := r.Repo.QueryJobs(ctx, filter, page, order)
|
||||||
|
if err != nil {
|
||||||
|
log.Warn("Error while querying next jobs")
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nextJobs) > 0 {
|
||||||
|
hasNextPage = true
|
||||||
|
}
|
||||||
|
|
||||||
|
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.
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
export let metrics = ccconfig.plot_list_selectedMetrics;
|
export let metrics = ccconfig.plot_list_selectedMetrics;
|
||||||
export let showFootprint;
|
export let showFootprint;
|
||||||
|
|
||||||
let usePaging = !!ccconfig.job_list_usePaging
|
let usePaging = ccconfig.job_list_usePaging
|
||||||
let itemsPerPage = usePaging ? ccconfig.plot_list_jobsPerPage : 10;
|
let itemsPerPage = usePaging ? ccconfig.plot_list_jobsPerPage : 10;
|
||||||
let page = 1;
|
let page = 1;
|
||||||
let paging = { itemsPerPage, page };
|
let paging = { itemsPerPage, page };
|
||||||
|
Loading…
Reference in New Issue
Block a user