Skip to content

Commit

Permalink
fix: revision count based limiting was broken on cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0elliot committed Jan 24, 2025
1 parent 57c97a8 commit e57c568
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
12 changes: 11 additions & 1 deletion db-connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -8020,9 +8020,11 @@ func ListWorkflowRevisions(ctx context.Context, originalId string, amount int) (
} else {
query := datastore.NewQuery(nameKey).Filter("id =", originalId)
// if project.Environment == "cloud" {
query = query.Order("-edited").Limit(amount)
query = query.Order("-edited")
// }

iterCount := 0

cursorStr := ""
for {
it := project.Dbclient.Run(ctx, query)
Expand All @@ -8038,7 +8040,15 @@ func ListWorkflowRevisions(ctx context.Context, originalId string, amount int) (
}
}

iterCount++;
workflows = append(workflows, innerWorkflow)
if iterCount >= amount {
break
}
}

if iterCount >= amount {
break
}

if err != iterator.Done {
Expand Down
15 changes: 12 additions & 3 deletions shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -6951,8 +6951,6 @@ func diffWorkflows(oldWorkflow Workflow, parentWorkflow Workflow, update bool) {

action.Parameters = finalParamters

// the updated action is given the right authentication ID every time.
log.Printf("[DEBUG] Authentication ID that's literally being passed in: %s", action.AuthenticationId)
childWorkflow.Actions[index] = action
break
}
Expand Down Expand Up @@ -28941,8 +28939,19 @@ func GetWorkflowRevisions(resp http.ResponseWriter, request *http.Request) {
}
}

revisionCount := 50
if request.URL.Query().Get("count") != "" {
revisionCount, err = strconv.Atoi(request.URL.Query().Get("count"))
if err != nil {
log.Printf("[WARNING] Failed converting count to int: %s", err)
resp.WriteHeader(400)
resp.Write([]byte(`{"success": false, "reason": "Failed converting count to int"}`))
return
}
}

// Access is granted -> get revisions
revisions, err := ListWorkflowRevisions(ctx, workflow.ID, 50)
revisions, err := ListWorkflowRevisions(ctx, workflow.ID, revisionCount)
if err != nil {
log.Printf("[WARNING] Failed getting revisions for workflow %s: %s", workflow.ID, err)
resp.WriteHeader(400)
Expand Down

0 comments on commit e57c568

Please sign in to comment.