Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/constant.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can keep the default length to 10. And please check for "grandmaster" rank it works or not.

Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ class Constant:

# Acronym MAX lenght
ACC_MAX_LEN = 6

# Rating MAX Length
ACC_RATING_MAX_LEN = 18
12 changes: 12 additions & 0 deletions app/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ def org_acronym(self):
acronym_handler = Acronym()
return acronym_handler.acronymize(self.organization)

@property
def rank_acronym(self):
"""Provides acronym of the rank"""
acronym_handler = Acronym()
return acronym_handler.acronymize(self.rank)

@property
def max_rank_acronym(self):
"""Provides acronym of the rank"""
acronym_handler = Acronym()
return acronym_handler.acronymize(self.max_rank)

@property
def sliced_name(self):
"""Provides a sliced name if the full name is too long."""
Expand Down
13 changes: 11 additions & 2 deletions app/services/stat_card_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,18 @@ def _get_card_svg(cls, config: Config) -> str:
output = re.sub('{{ organization }} \|', user.org_acronym, output)
else:
output = re.sub('{{ organization }}', user.org_acronym, output)
output = re.sub('{{ rating }}', user.rank, output)

if len(user.rank) > Constant.ACC_RATING_MAX_LEN:
output = re.sub('{{ rating }}', user.rank_acronym, output)
else:
output = re.sub('{{ rating }}', user.rank, output)

if len(user.rank) > Constant.ACC_RATING_MAX_LEN:
output = re.sub('{{ max }}', user.max_rank_acronym, output)
else:
output = re.sub('{{ max }}', user.max_rank, output)

output = re.sub('green', user.rating_color, output)
output = re.sub('{{ max }}', user.max_rank, output)
output = re.sub('#03A89E', user.max_rating_color, output)
output = re.sub('{{ year }}', str(user.member_since), output)
output = re.sub('{{ contest_rating }}', str(user.rating), output)
Expand Down