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

Promotions should be sorted lexicographically #1930

Closed
hiddeco opened this issue May 2, 2024 · 9 comments · Fixed by #1949
Closed

Promotions should be sorted lexicographically #1930

hiddeco opened this issue May 2, 2024 · 9 comments · Fixed by #1949
Assignees
Labels
area/api good first issue Good issue for a new contributor to handle help-wanted Community help on this would be appreciated kind/bug priority/normal size/tiny Less than 1 hour of work
Milestone

Comments

@hiddeco
Copy link
Contributor

hiddeco commented May 2, 2024

The UI API server appears to order Promotions for a Stage by their Phase and creation timestamp. However, as the creation timestamp does not include nanoseconds, this approach will fail when multiple Promotions are (programmatically) created within a short period.

To address this issue, it should use the ULID in the Promotion name, which allows it to be lexicographically sorted beyond the creation timestamp of the Promotion.

@hiddeco hiddeco added this to the v0.7.0 milestone May 2, 2024
@hiddeco hiddeco changed the title Promotions should be sorted lexographically Promotions should be sorted lexicographically May 2, 2024
@krancour krancour added good first issue Good issue for a new contributor to handle size/tiny Less than 1 hour of work help-wanted Community help on this would be appreciated labels May 2, 2024
@webstradev
Copy link
Contributor

Is this done by parsing the promotion name "shortName.ulid.shorthash" (maybe making a helper function on the Promotion struct for that) and sorting on that instead of the creation time?

@hiddeco
Copy link
Contributor Author

hiddeco commented May 3, 2024

It would not require parsing, the ULID component in the name would make any list entry sortable by default.

@hiddeco
Copy link
Contributor Author

hiddeco commented May 3, 2024

To clarify: as far as I am aware this is a frontend issue which would not require any changes to the backend.

@hiddeco
Copy link
Contributor Author

hiddeco commented May 3, 2024

See also:

export const sortPromotions = (a: Promotion, b: Promotion) => {

@webstradev
Copy link
Contributor

webstradev commented May 3, 2024

It would not require parsing, the ULID component in the name would make any list entry sortable by default.

Ah I see I didn't realize we are always dealing with the same prefix (stage name) so we can indeed just sort on the Name.

Are you sure we should be sorting this in the frontend and not in the api though.

I know the frontend is also sorting it, but shouldn't we aim to sort it in the backend in general is more the quest

@webstradev
Copy link
Contributor

Maybe doing so doesn't solve the issue you originally raised, as you still have some more "advanced" sorting in the frontend with running promotions versus non running. But it would I believe still make sense to change this in the API as well, to ensure we are returning properly sorted results there as well.

@krancour
Copy link
Member

krancour commented May 3, 2024

Agree it's ideally a back end change. Re-labeling accordingly.

@krancour krancour added area/api and removed area/ui labels May 3, 2024
@webstradev
Copy link
Contributor

Ill work on this.

@krancour
Copy link
Member

krancour commented May 3, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api good first issue Good issue for a new contributor to handle help-wanted Community help on this would be appreciated kind/bug priority/normal size/tiny Less than 1 hour of work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants