Skip to content

Commit

Permalink
Merge pull request #471 from alessandro-sorint/fix-cursors
Browse files Browse the repository at this point in the history
gateway: fix api cursors
  • Loading branch information
sgotti authored Jan 8, 2024
2 parents 313b5bc + 49bb1fc commit 1ac1c71
Show file tree
Hide file tree
Showing 6 changed files with 742 additions and 394 deletions.
5 changes: 4 additions & 1 deletion internal/services/gateway/action/commitstatusdelivery.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ func (h *ActionHandler) GetProjectCommitStatusDeliveries(ctx context.Context, re
var outCursor string
if resp.HasMore && len(commitStatusDeliveries) > 0 {
lastCommitStatusDeliverySequence := commitStatusDeliveries[len(commitStatusDeliveries)-1].Sequence
outCursor, err = MarshalCursor(&StartSequenceCursor{StartSequence: lastCommitStatusDeliverySequence})
outCursor, err = MarshalCursor(&StartSequenceCursor{
StartSequence: lastCommitStatusDeliverySequence,
SortDirection: sortDirection,
})
if err != nil {
return nil, errors.WithStack(err)
}
Expand Down
10 changes: 8 additions & 2 deletions internal/services/gateway/action/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ func (h *ActionHandler) GetOrgs(ctx context.Context, req *GetOrgsRequest) (*GetO
var outCursor string
if resp.HasMore && len(orgs) > 0 {
lastRemoteSourceName := orgs[len(orgs)-1].Name
outCursor, err = MarshalCursor(&StartCursor{Start: lastRemoteSourceName})
outCursor, err = MarshalCursor(&StartCursor{
Start: lastRemoteSourceName,
SortDirection: sortDirection,
})
if err != nil {
return nil, errors.WithStack(err)
}
Expand Down Expand Up @@ -146,7 +149,10 @@ func (h *ActionHandler) GetOrgMembers(ctx context.Context, req *GetOrgMembersReq
var outCursor string
if resp.HasMore && len(orgMembers) > 0 {
lastUserName := orgMembers[len(orgMembers)-1].User.Name
outCursor, err = MarshalCursor(&StartCursor{Start: lastUserName})
outCursor, err = MarshalCursor(&StartCursor{
Start: lastUserName,
SortDirection: sortDirection,
})
if err != nil {
return nil, errors.WithStack(err)
}
Expand Down
5 changes: 4 additions & 1 deletion internal/services/gateway/action/remotesource.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ func (h *ActionHandler) GetRemoteSources(ctx context.Context, req *GetRemoteSour
var outCursor string
if resp.HasMore && len(remoteSources) > 0 {
lastRemoteSourceName := remoteSources[len(remoteSources)-1].Name
outCursor, err = MarshalCursor(&StartCursor{Start: lastRemoteSourceName})
outCursor, err = MarshalCursor(&StartCursor{
Start: lastRemoteSourceName,
SortDirection: sortDirection,
})
if err != nil {
return nil, errors.WithStack(err)
}
Expand Down
5 changes: 4 additions & 1 deletion internal/services/gateway/action/runwebhookdelivery.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ func (h *ActionHandler) GetProjectRunWebhookDeliveries(ctx context.Context, req
var outCursor string
if resp.HasMore && len(runWebhookDeliveries) > 0 {
lastRunWebhookDeliverySequence := runWebhookDeliveries[len(runWebhookDeliveries)-1].Sequence
outCursor, err = MarshalCursor(&StartSequenceCursor{StartSequence: lastRunWebhookDeliverySequence})
outCursor, err = MarshalCursor(&StartSequenceCursor{
StartSequence: lastRunWebhookDeliverySequence,
SortDirection: sortDirection,
})
if err != nil {
return nil, errors.WithStack(err)
}
Expand Down
10 changes: 8 additions & 2 deletions internal/services/gateway/action/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ func (h *ActionHandler) GetUserOrgs(ctx context.Context, req *GetUserOrgsRequest
var outCursor string
if resp.HasMore && len(orgs) > 0 {
lastOrgName := orgs[len(orgs)-1].Organization.Name
outCursor, err = MarshalCursor(&StartCursor{Start: lastOrgName})
outCursor, err = MarshalCursor(&StartCursor{
Start: lastOrgName,
SortDirection: sortDirection,
})
if err != nil {
return nil, errors.WithStack(err)
}
Expand Down Expand Up @@ -174,7 +177,10 @@ func (h *ActionHandler) GetUsers(ctx context.Context, req *GetUsersRequest) (*Ge
var outCursor string
if resp.HasMore && len(csusers) > 0 {
lastUserName := csusers[len(csusers)-1].Name
outCursor, err = MarshalCursor(&StartCursor{Start: lastUserName})
outCursor, err = MarshalCursor(&StartCursor{
Start: lastUserName,
SortDirection: sortDirection,
})
if err != nil {
return nil, errors.WithStack(err)
}
Expand Down
Loading

0 comments on commit 1ac1c71

Please sign in to comment.