We should be able to sort a stack of Badges by highest quality -> shoddiest.
Description
Revisions and Commits
Event Timeline
It's currently impossible to sort badges by rarity because they rarities are internally 'grey', 'white', 'green', etc., and there is no natural order to these. For example, MySQL has no idea what order 'indigo', 'orange' and 'yellow' should go in, except alphabetical, which is not actually the correct order.
I think the cleanest fix here is:
- Replace rarity constants (like grey, white, ...) with quality codes (like 10, 20, ...).
- Replace the quality string column (currently text255) with a uint32 column so MySQL can sort it.
- Add sort options to the UI.
Leaving some room between quality levels will give us more flexibility in the future if we want to add new quality levels or make them user-customizable.
Reasonable approach might be:
Extract the badge quality constants, names, etc., into a new PhabricatorBadgesQuality class or similar. You can look at HarbormasterUnitStatus for a reasonable sort of example of what this might look like.
The actual qualities should probably be defined somewhere as:
return array( 10 => array( 'color' => 'grey', 'name' => pht('Poor'), ), 20 => array( 'color' => 'white', 'name' => pht('Common'), ), ...
This will make it easy to extract them into some badges.quality-options config down the road if we want. I don't currently really anticipate doing this, but there are no drawbacks to preparing for the possibility.
Then migrate all the existing qualities:
UPDATE badge SET quality = 10 WHERE quality = 'grey';
And then change the column type to uint32 / INT UNSIGNED NOT NULL.
To make this sortable in the UI, modify PhabricatorBadgesQuery and implement getBuiltinOrders(), getOrderableColumns() and getPagingValueMap(). You can look at existing implementations of these for examples. The ordering option should automatically appear in the UI (and work properly) once these are implemented.
It was mostly a comment that the title of this task was "Allow Badges to be ordered by Rarity" as in Rarity from My Little Pony and not just rarity.
Haha. Yes, well, you claim in another file that it was WoW colors. Get your story straight, @chad !
FUN POLICE HERE
TOO MUCH FUN DETECTED
THE TECHNICAL TERM FOR THIS PROPERTY IS "QUALITY"
Wait are they not Blizzard colors any more? My team can't handle using different colors from WoW and Diablo III and will find this feature too confusing if they have to learn about ponies too. Phabricator is ruined forever.