API ListActionTasks is not sorted chronologically #13019

Closed
opened 2025-11-02 10:27:50 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @mattfysh on GitHub (May 24, 2024).

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?

ec771fdfcd/routers/api/v1/repo/action.go (L562-L565)

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

Originally created by @mattfysh on GitHub (May 24, 2024). ### 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? https://github.com/go-gitea/gitea/blob/ec771fdfcdbc74320b1ef0252444aa5cddd50a04/routers/api/v1/repo/action.go#L562-L565 ### 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
GiteaMirror added the type/enhancement label 2025-11-02 10:27:50 -06:00
Author
Owner

@lunny commented on GitHub (May 24, 2024):

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

@lunny commented on GitHub (May 24, 2024): It's sorted by created time. I don't think it's a bug maybe an enhancement is better.
Author
Owner

@mattfysh commented on GitHub (May 24, 2024):

Hi Lunny, I’m not seeing it being sorted that way when I call the API, and
if you look at the source code I linked to you see there is no order clause
given to the FindAndCount method

On Fri, 24 May 2024 at 1:02 PM, Lunny Xiao @.***> wrote:

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


Reply to this email directly, view it on GitHub
https://github.com/go-gitea/gitea/issues/31066#issuecomment-2128425381,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AADSZ4R25KN2O5NPN5E6PVTZD2UVVAVCNFSM6AAAAABIGXMI76VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRYGQZDKMZYGE
.
You are receiving this because you authored the thread.Message ID:
@.***>

@mattfysh commented on GitHub (May 24, 2024): Hi Lunny, I’m not seeing it being sorted that way when I call the API, and if you look at the source code I linked to you see there is no order clause given to the FindAndCount method On Fri, 24 May 2024 at 1:02 PM, Lunny Xiao ***@***.***> wrote: > It's sorted by created time. I don't think it's a bug maybe an enhancement > is better. > > — > Reply to this email directly, view it on GitHub > <https://github.com/go-gitea/gitea/issues/31066#issuecomment-2128425381>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AADSZ4R25KN2O5NPN5E6PVTZD2UVVAVCNFSM6AAAAABIGXMI76VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRYGQZDKMZYGE> > . > You are receiving this because you authored the thread.Message ID: > ***@***.***> >
Author
Owner

@lunny commented on GitHub (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.

@lunny commented on GitHub (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`.
Author
Owner

@mattfysh commented on GitHub (May 24, 2024):

I’m not sure what the confusion is here but you’re saying that the endpoint
is sorted and I’m telling you it’s not

On Fri, 24 May 2024 at 2:02 PM, Lunny Xiao @.***> wrote:

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.


Reply to this email directly, view it on GitHub
https://github.com/go-gitea/gitea/issues/31066#issuecomment-2128481259,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AADSZ4TKWZRBFWVJIKESHQ3ZD23WXAVCNFSM6AAAAABIGXMI76VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRYGQ4DCMRVHE
.
You are receiving this because you authored the thread.Message ID:
@.***>

@mattfysh commented on GitHub (May 24, 2024): I’m not sure what the confusion is here but you’re saying that the endpoint is sorted and I’m telling you it’s not On Fri, 24 May 2024 at 2:02 PM, Lunny Xiao ***@***.***> wrote: > 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. > > — > Reply to this email directly, view it on GitHub > <https://github.com/go-gitea/gitea/issues/31066#issuecomment-2128481259>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AADSZ4TKWZRBFWVJIKESHQ3ZD23WXAVCNFSM6AAAAABIGXMI76VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRYGQ4DCMRVHE> > . > You are receiving this because you authored the thread.Message ID: > ***@***.***> >
Author
Owner

@mattfysh commented on GitHub (May 24, 2024):

the web runtime correctly does a FindAndCount with ordering declared:

ec771fdfcd/routers/web/shared/actions/runners.go (L77-L85)

the API runtime does not:

ec771fdfcd/routers/api/v1/repo/action.go (L562-L565)

@mattfysh commented on GitHub (May 24, 2024): the web runtime correctly does a FindAndCount with ordering declared: https://github.com/go-gitea/gitea/blob/ec771fdfcdbc74320b1ef0252444aa5cddd50a04/routers/web/shared/actions/runners.go#L77-L85 the API runtime does not: https://github.com/go-gitea/gitea/blob/ec771fdfcdbc74320b1ef0252444aa5cddd50a04/routers/api/v1/repo/action.go#L562-L565
Author
Owner

@mattfysh commented on GitHub (May 24, 2024):

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?

@mattfysh commented on GitHub (May 24, 2024): 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?
Author
Owner

@wolfogre commented on GitHub (May 29, 2024):

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

@wolfogre commented on GitHub (May 29, 2024): > 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
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#13019