Page MenuHomePhabricator

Allow Badges to be ordered by quality
Closed, ResolvedPublic

Description

We should be able to sort a stack of Badges by highest quality -> shoddiest.

Event Timeline

chad created this task.Jul 29 2015, 10:44 PM
chad raised the priority of this task from to Needs Triage.
chad updated the task description. (Show Details)
chad added a project: Badges.
chad moved this task to v1 on the Badges board.
chad added a subscriber: chad.
chad moved this task from v1 to Backlog on the Badges board.Feb 6 2016, 5:55 AM
epriestley added a subscriber: epriestley.

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.

epriestley moved this task from Backlog to v0 on the Badges board.Mar 25 2016, 7:10 PM
epriestley edited projects, added Badges (v0); removed Badges.

Did I get the colors wrong? I thought I copied them as they were...

chad added a comment.Apr 1 2016, 2:09 AM

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.

chad added a comment.Apr 1 2016, 2:12 AM

I guess I am the only one with elite Pony knowledge here.

Haha. Yes, well, you claim in another file that it was WoW colors. Get your story straight, @chad !

chad added a comment.Apr 1 2016, 2:14 AM

Ouch. Burned.

cburroughs added a subscriber: cburroughs.

FUN POLICE HERE

siren

TOO MUCH FUN DETECTED

siren

THE TECHNICAL TERM FOR THIS PROPERTY IS "QUALITY"

siren

epriestley renamed this task from Allow Badges to be ordered by Rarity to Allow Badges to be ordered by quality.Apr 1 2016, 1:15 PM
epriestley updated the task description. (Show Details)

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.

Too many deck slots, product literally unplayable.

lpriestley closed this task as Resolved.Apr 1 2016, 7:01 PM
urzds added a subscriber: urzds.Jul 12 2017, 11:08 AM