@@ -32,7 +32,7 @@ def db_stats(connection, stamp=None) -> list:
3232 f"SELECT cmc, COUNT(*) as Mana FROM cards { timestamp_query } GROUP BY cmc"
3333 )
3434 curve = cursor .fetchall ()
35- stats .append (f"MANA CURVE:\n { chart_data (curve , total_cards )} " )
35+ stats .append (f" MANA CURVE:\n { chart_data (curve , total_cards )} " )
3636
3737 # Colour distribution
3838 cursor .execute (
@@ -45,25 +45,38 @@ def db_stats(connection, stamp=None) -> list:
4545 ORDER BY color_count DESC
4646 """
4747 )
48-
4948 curve = cursor .fetchall ()
5049 coloured_results = [[scryfall_colours (id ), count ] for id , count in curve ]
5150
5251 stats .append (
53- f"COLOUR DISTRIBUTION:\n { chart_data (coloured_results , total_cards )} "
52+ f" COLOUR DISTRIBUTION:\n { chart_data (coloured_results , total_cards )} "
53+ )
54+
55+ # Rarity distribution
56+ cursor .execute (
57+ f"""SELECT
58+ rarity,
59+ COUNT(rarity) AS rarity_count
60+ FROM cards
61+ { timestamp_query }
62+ GROUP BY rarity
63+ ORDER BY rarity_count DESC
64+ """
5465 )
66+ curve = cursor .fetchall ()
67+ stats .append (f" RARITY DISTRIBUTION:\n { chart_data (curve , total_cards )} " )
5568
5669 # Tally of card types
5770 cursor .execute (
5871 report_card_types (timestamp_query )[0 ], report_card_types (timestamp_query )[1 ]
5972 )
6073 curve = cursor .fetchall ()
61- stats .append (f"CARD TYPES:\n { chart_data (curve , total_cards )} " )
74+ stats .append (f" CARD TYPES:\n { chart_data (curve , total_cards )} " )
6275
6376 # Prices: highest and average
64- stats .append ("PRICES:\n " )
77+ stats .append (" PRICES:" )
6578 stats .append (
66- f" Average Price is { report_prices (cursor ,timestamp_query )[1 ]} EUR\n "
79+ f" Average Price is { report_prices (cursor ,timestamp_query )[1 ]} EUR"
6780 )
6881 stats .append ("\n " .join (report_prices (cursor , timestamp_query )[0 ]))
6982 stats .append ("" )
@@ -107,7 +120,7 @@ def get_unique_cards(connection, timestamp=None) -> int | str:
107120def chart_data (curve_data , total_cards ):
108121 if total_cards < 1 :
109122 return "Could not chart data. Not enough cards."
110- print_curve = "\n "
123+ print_curve = ""
111124 percentage_steps = 2 # each block is x%
112125 scale = 100 / total_cards
113126
0 commit comments