Small update, we can't use a default_scope, as this will change behaviour for the blob and commit controller. I'll probably just edit the EnvironmentsFinder to do this, but this will require us to use this in the environments controller too.
But I start to wonder if this is actually what we want. @markpundsack implies this is a bug, but the environments are sorted already, on the name, which its also GROUP BYed. It seems we would be changing behaviour. Could you confirm @markpundsack, as it seems it works better this way than what you propose.
Updated by will almost always get staging and review apps as top result, but probably alphabetically sorted is better?
@zj When I reported the bug, the environment lists for folders was not sorted alphabetically, iirc. Sorting alphabetically is better than nothing, but for long lists of review apps, alphabetically isn't particularly useful.
I agree that the top-level environment list should probably be alphabetically sorted just so it stays static. Ideally, it would actually be sorted based on semantic interpretation of the environment names (review -> dev[elopment] -> staging -> qa -> UAT -> prod[uction)
I wonder how you'd like to achieve this, without hardcoding it?
Anyway, indeed, the main list is sorted, inside not so much. I'll update the issue to reflect it. Please be more specific next time you open an issue like this
Zeger-Jan van de Wegchanged title from Sort environment folders to Sort environments inside environment folders
changed title from Sort environment folders to Sort environments inside environment folders