Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API ListActionTasks is not sorted chronologically #31066

Closed
mattfysh opened this issue May 24, 2024 · 7 comments · Fixed by #31150
Closed

API ListActionTasks is not sorted chronologically #31066

mattfysh opened this issue May 24, 2024 · 7 comments · Fixed by #31150
Labels
type/enhancement An improvement of existing functionality

Comments

@mattfysh
Copy link

Description

These are currently randomly sorted. Can they be updated to be sorted in reverse chronological order, i.e. the same as the Web UI?

tasks, total, err := db.FindAndCount[actions_model.ActionTask](ctx, &actions_model.FindTaskOptions{
ListOptions: utils.GetListOptions(ctx),
RepoID: ctx.Repo.Repository.ID,
})

Gitea Version

1.22.0+rc1-106-gedbf74c418

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Via the helm chart

Database

None

@lunny
Copy link
Member

lunny commented May 24, 2024

It's sorted by created time. I don't think it's a bug maybe an enhancement is better.

@lunny lunny added type/enhancement An improvement of existing functionality and removed type/bug labels May 24, 2024
@mattfysh
Copy link
Author

mattfysh commented May 24, 2024 via email

@lunny
Copy link
Member

lunny commented May 24, 2024

Yes, there is no explicit order clause in FindAndCount. So the database should have a default one. Commonly it should be the id asc which is the same order as the created.

@mattfysh
Copy link
Author

mattfysh commented May 24, 2024 via email

@mattfysh
Copy link
Author

the web runtime correctly does a FindAndCount with ordering declared:

opts := actions_model.FindTaskOptions{
ListOptions: db.ListOptions{
Page: page,
PageSize: 30,
},
Status: actions_model.StatusUnknown, // Unknown means all
IDOrderDesc: true,
RunnerID: runner.ID,
}

the API runtime does not:

tasks, total, err := db.FindAndCount[actions_model.ActionTask](ctx, &actions_model.FindTaskOptions{
ListOptions: utils.GetListOptions(ctx),
RepoID: ctx.Repo.Repository.ID,
})

@mattfysh
Copy link
Author

following up on request from @lunny in discord

Could you give some proposals which order options should the API provide

I propose that the API should return the workflow_runs in the same order that the web runtime currently sorts the list, ie. add IDOrderDesc: true

@chesteripz @wolfogre do you have any thoughts?

@wolfogre
Copy link
Member

you’re saying that the endpoint is sorted and I’m telling you it’s not

In the absence of an explicit ORDER BY clause, different databases may return query results in varying orders due to their unique underlying implementations and optimizations.

So I believe @mattfysh did meet a "random" order result via API.

I propose that the API should return the workflow_runs in the same order that the web runtime currently sorts the list

It makes sense. I think we can just drop the option IDOrderDesc, since it will be useless if it always true, and it is what FindRunOptions and FindScheduleOptions do.

So #31150

lunny pushed a commit that referenced this issue May 31, 2024
…ESC` (#31150)

Close #31066

Just follow what `FindRunOptions` and `FindScheduleOptions` do.
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Aug 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants