Skip to content

Commit

Permalink
refactor(schema): Ensure missing rarities are always sorted alphabeti…
Browse files Browse the repository at this point in the history
…cally

Signed-off-by: Chris <[email protected]>
  • Loading branch information
Investigamer committed Aug 28, 2024
1 parent 0d00a37 commit 887e02f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ def build(cls, icon: str = '', set_code: str = '') -> 'Icon':

# Build directory path and discover missing rarities
_path = Path(Paths.SET, icon.upper())
_missing = [
_missing = sorted(
n for n in REQUIRED_RARITIES
if not Path(_path, n).with_suffix('.svg').is_file()
]
)

# Return generated Icon object
return Icon(
Expand Down Expand Up @@ -107,10 +107,10 @@ def get_missing_rarities(cls, items: list['Icon']) -> list['Icon']:
# Get items with missing rarities
_items = [n for n in items if n.exists and n.missing]

# Sort alphabetically
# Secondary sort: alphabetical (ascending)
_items = sorted(_items, key=lambda n: n.icon)

# Sort by number if rarities missing
# Primary sort: number missing (descending)
return sorted(_items, key=lambda n: len(n.missing), reverse=True)


Expand Down

0 comments on commit 887e02f

Please sign in to comment.