-
Notifications
You must be signed in to change notification settings - Fork 109
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
feat: (api/ui) Sort promotions lexicographically #1949
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Erik Westra <e.s.westra.95@gmail.com>
…reation time. Signed-off-by: Erik Westra <e.s.westra.95@gmail.com>
✅ Deploy Preview for docs-kargo-akuity-io ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1949 +/- ##
==========================================
+ Coverage 46.20% 46.25% +0.04%
==========================================
Files 235 235
Lines 15990 16004 +14
==========================================
+ Hits 7388 7402 +14
+ Misses 8244 8242 -2
- Partials 358 360 +2 ☔ View full report in Codecov by Sentry. |
Ah... I think when commenting on #1930, I failed to realize that both the API server and UI were sorting these. I would prefer the sorting to be done only on the back end, but I will ask @rbreeze to also weigh in on this opinion in case there are UI-specific reasons I am unaware of for sorting any differently than what the API server will return. |
All good, let me know if you want me to move it completely from UI to the API. I'm pretty sure it should be easy enough, but just to confirm they are currently different. Backend only sorts on creationTime |
@rbreeze was this intended? Sorting by time should be adequate, right? In case it's not clear... promos are always processed in the order they were created. |
Just for your clarity @krancour
|
The way I feel you want them sorted in the UI (and arguably the API), is a bit awkward. For things which are non-terminal (Running and Pending), you want them to be from oldest -> newest. Because that's how the queue is going through them. For things which are terminal however (Succeeded, Errored, etc.), you want them from newest -> oldest. Because that gives you the latest Promotion which has been processed first. Non-terminal should then go before terminal, to ensure the user has a clear view of what's being worked on. I already wrote something which handles this type of ordering (in Go) in #1919. |
So are we moving this completely from frontend to backend then and keeping all the sorting logic in the backend? |
I think we would at least want it in the API, and for the frontend we have to await further instructions from @rbreeze. |
I have no opposition to sorting lexicographically on the backend, and agree that we should rely on the backend to sort... with one caveat. The background for why the UI does sorting as it does can be found in this PR and the linked issue: #1314 To summarize, currently running promotions were often buried on the last page where they were difficult to find. Hence the phase creeping into the sorting logic. I don't think this PR will affect that logic. |
Well the PR as it is currently I think is mergeable, but the suggestion was to move the sorting logic completely to the backend, and removing sorting all together from the frontend (whilst keeping the same sorting logic as describe in #1314) Happy to change it to that if everyone is in agreement. |
@webstradev Got it, makes sense. I am okay with either way. IMO the frontend sorting logic to surface currently running promotions is more of a UI feature than a "sort". So it comes down to whether we think this surfacing of running promos should happen at the API level (and therefore change the behavior of the CLI). WDYT @hiddeco @krancour ? |
As the phase is also being shown for |
Also agree with @hiddeco's suggestions in #1949 (comment) |
We're looking at a v0.7.0 release toward the end of this week. @webstradev should we defer this to v0.8.0? |
yeah sorry I've been quite busy and I've got some holidays coming up. So either defer or happy to have someone else take it over and use what I wrote so far. |
Closes #1930
This PR handles sorting of promotions in two places.
In the api call we simply sort on the Name which contains a prefix that is always the same for promotions you want to sort followed by a ULID. I have also adjusted the tests to test for this sorting instead of on creation time. I do this by simply creating for ULID and using them in the tests.
In te UI we have slightly more complex sorting logic and I'm not certain we want that in the API, so I have essentially made the same change in the sortPromotions function. Instead of sorting on create time we sort simply on name. I didin't use ULIDs here in the tests because it doesn't make sense to me to die the frontend to that implementation, so I just used lexicographically sortable strings in the ui tests as well.