diff --git a/decksite/data/archetype.py b/decksite/data/archetype.py index b50106834..5b24eb891 100644 --- a/decksite/data/archetype.py +++ b/decksite/data/archetype.py @@ -41,6 +41,7 @@ def load_competition_archetypes(competition_id: int) -> list[Archetype]: IFNULL(SUM(dsum.wins), 0) AS wins, IFNULL(SUM(dsum.losses), 0) AS losses, IFNULL(SUM(dsum.draws), 0) AS draws, + SUM(IFNULL(dsum.wins, 0) - IFNULL(dsum.losses, 0)) AS record, SUM(CASE WHEN dsum.wins >= 5 AND dsum.losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs, SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins, SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s, diff --git a/decksite/data/card.py b/decksite/data/card.py index 297eb2cad..91f0b2586 100644 --- a/decksite/data/card.py +++ b/decksite/data/card.py @@ -17,6 +17,7 @@ def load_competition_cards(competition_id: int, order_by: str, limit: str) -> tu IFNULL(SUM(dsum.losses), 0) AS losses, IFNULL(SUM(dsum.draws), 0) AS draws, SUM(IFNULL(dsum.wins, 0) - IFNULL(dsum.losses, 0)) AS record, + SUM(CASE WHEN dsum.wins >= 5 AND dsum.losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs, SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins, SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s, IFNULL(ROUND((SUM(dsum.wins) / NULLIF(SUM(dsum.wins + dsum.losses), 0)) * 100, 1), '') AS win_percent, diff --git a/decksite/templates/archetypetree.mustache b/decksite/templates/archetypetree.mustache index 753d626de..5fde206b3 100644 --- a/decksite/templates/archetypetree.mustache +++ b/decksite/templates/archetypetree.mustache @@ -7,12 +7,14 @@ {{/is_matchups}} Record Win % - {{^is_matchups}} - - {{/is_matchups}} - {{^is_matchups}} - - {{/is_matchups}} + {{^hide_tournament_results}} + + + + + + + {{/hide_tournament_results}} {{^is_matchups}}{{^hide_perfect_runs}} 5–0s {{/hide_perfect_runs}}{{/is_matchups}} @@ -28,8 +30,10 @@ {{/is_matchups}} {{#show_record}}{{wins}}–{{losses}}{{#draws}}–{{draws}}{{/draws}}{{/show_record}} {{#show_record}}{{win_percent}}{{/show_record}} - {{^is_matchups}}{{#tournament_top8s}}{{tournament_wins}}{{/tournament_top8s}}{{/is_matchups}} - {{^is_matchups}}{{#tournament_top8s}}{{tournament_top8s}}{{/tournament_top8s}}{{/is_matchups}} + {{^hide_tournament_results}} + {{#tournament_top8s}}{{tournament_wins}}{{/tournament_top8s}} + {{#tournament_top8s}}{{tournament_top8s}}{{/tournament_top8s}} + {{/hide_tournament_results}} {{^is_matchups}}{{^hide_perfect_runs}}{{#perfect_runs}}{{perfect_runs}}{{/perfect_runs}}{{/hide_perfect_runs}}{{/is_matchups}} {{/hide_archetype}} diff --git a/decksite/templates/livecardtable.mustache b/decksite/templates/livecardtable.mustache index a2390e53d..05263e275 100644 --- a/decksite/templates/livecardtable.mustache +++ b/decksite/templates/livecardtable.mustache @@ -5,6 +5,7 @@ data-archetype-id="{{archetype.id}}" data-base-query="{{base_query}}" data-competition-id="{{competition_id}}" + data-league-only="{{#league_only}}1{{/league_only}}" data-person-id="{{person.id}}" data-season-id="{{season_id}}" data-tournament-only="{{#tournament_only}}1{{/tournament_only}}"> diff --git a/decksite/views/archetype.py b/decksite/views/archetype.py index e68c66793..0b190cf75 100644 --- a/decksite/views/archetype.py +++ b/decksite/views/archetype.py @@ -14,6 +14,7 @@ class Matchups(TypedDict): is_matchups: bool + hide_tournament_results: bool archetypes: list[archs.Archetype] class Archetype(View): @@ -30,6 +31,7 @@ def __init__(self, archetype: archs.Archetype, archetypes: list[archs.Archetype] break self.matchups: Matchups = { 'is_matchups': True, + 'hide_tournament_results': True, 'archetypes': copy.deepcopy(archetypes), # Take a copy of the archetypes, so we can update their stats without interfering with the other section. } matchups_by_id = {m.id: m for m in matchups} diff --git a/decksite/views/competition.py b/decksite/views/competition.py index 6880ffb81..f25307139 100644 --- a/decksite/views/competition.py +++ b/decksite/views/competition.py @@ -22,6 +22,8 @@ def __init__(self, competition: Comp, archetypes: list[Archetype]) -> None: self.date = dtutil.display_date(competition.start_date) self.archetypes = archetypes self.show_archetype_tree = len(self.archetypes) > 0 + self.hide_perfect_runs = self.tournament_only = competition.type != 'League' + self.league_only = self.hide_tournament_results = competition.type == 'League' def __getattr__(self, attr: str) -> Any: return getattr(self.competition, attr) diff --git a/shared_web/static/js/cardtable.jsx b/shared_web/static/js/cardtable.jsx index 43f910ac5..5c6e9cbc1 100644 --- a/shared_web/static/js/cardtable.jsx +++ b/shared_web/static/js/cardtable.jsx @@ -8,12 +8,18 @@ const renderHeaderRow = (table) => ( # Decks Record Win % - - - - - - + { table.props.leagueOnly + ? null + : + + + } + { table.props.leagueOnly + ? null + : + + + } { table.props.tournamentOnly ? null : 5–0s @@ -27,18 +33,24 @@ const renderRow = (table, card) => ( {card.numDecks} {renderRecord(card)} {renderWinPercent(card)} - - { card.tournamentWins > 0 - ? card.tournamentWins - : "" - } - - - { card.tournamentTop8s > 0 - ? card.tournamentTop8s - : "" - } - + { table.props.leagueOnly + ? null + : + { card.tournamentWins > 0 + ? card.tournamentWins + : "" + } + + } + { table.props.leagueOnly + ? null + : + { card.tournamentTop8s > 0 + ? card.tournamentTop8s + : "" + } + + } { table.props.tournamentOnly ? null :