3cb-data

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.alexwennerberg.com/3cb-data.git
Log | Files | Refs | README | LICENSE

commit cbd60818b49ac5930160f4ed0c81271c268f24f4
parent da59a3988c9e299ff99079d21c583eb70bc54c25
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Thu, 22 Feb 2024 21:20:08 -0500

bolding new cards in templates

Diffstat:
Mbuildpage.py | 1+
Mgetdata.py | 1+
Mrunround.sh | 6+++++-
Msql/delete-last.sql | 6+++---
Msql/export.sql | 41++++++++++++++++-------------------------
Mtemplates/index.html | 9++++++---
6 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/buildpage.py b/buildpage.py @@ -11,6 +11,7 @@ def card_link(card): return f"https://scryfall.com/search?q={urllib.parse.quote_plus(card)}" env.filters['card_link'] = card_link +env.filters['zip'] = zip def rows_to_dict(res): desc = res.description diff --git a/getdata.py b/getdata.py @@ -149,6 +149,7 @@ def best_guess(card): def replacement(card): m = { + "Thallid Oh Yeah": "Thallid", "Forest!!!!!!": "Forest", "Bottomless Depths": "Bottomless Vault", "Gargadon (Neither Greater Nor lesser": "Gargadon", diff --git a/runround.sh b/runround.sh @@ -1,3 +1,7 @@ +sqlite3 3cb.db < sql/delete-last.sql python getdata.py sqlite3 3cb.db < sql/new.sql -sqlite3 3cb.db < sql/export.sql > export.tsv +sqlite3 3cb.db < sql/export.sql > _site/export.tsv +python3 buildpage.py > _site/index.html +rsync -r _site/ root@pi:/var/www/data.3cardmagic.org + diff --git a/sql/delete-last.sql b/sql/delete-last.sql @@ -1,3 +1,3 @@ -delete from round where id > 50; -delete from deck where round > 50; -delete from match where round > 50; +delete from round where id > 53; +delete from deck where round > 53; +delete from match where round > 53; diff --git a/sql/export.sql b/sql/export.sql @@ -8,41 +8,32 @@ select round,player,card1 as card from deck union select round,player,card2 as card from deck union select round,player,card3 as card from deck), -ranked_cards as ( -select - card.card, - card.round, - card.player, - /* adjust by 100 for finals */ - sum(case when match.group_name = 'final' then match.score * 100 else match.score end) as score - from card - join match on card.round = match.round and card.player = match.player -group by 1,2), - -top_scores as ( -select card, round, player, max(score) as score from ranked_cards group by 1), +firsts as ( + select card,min(round) as first_round from card + group by 1 +), summary as (select deck.round,deck.player, card1, card2, card3, -ts1.score is not null as card1top, -ts2.score is not null as card2top, -ts3.score is not null as card3top, +f1.card is not null as card1new, +f2.card is not null as card2new, +f3.card is not null as card3new, min(match.group_name) as prelim_group, sum(case when match.group_name != 'final' then match.score else 0 end) as prelim_score, sum(case when match.group_name = 'final' then match.score else null end) as final_score from deck join match on deck.round = match.round and deck.player = match.player -left join top_scores ts1 -on deck.round = ts1.round -and deck.card1 = ts1.card -left join top_scores ts2 -on deck.round = ts2.round -and deck.card2 = ts2.card -left join top_scores ts3 -on deck.round = ts3.round -and deck.card3 = ts3.card +left join firsts f1 +on f1.card = deck.card1 +and f1.first_round = deck.round +left join firsts f2 +on f2.card = deck.card2 +and f2.first_round = deck.round +left join firsts f3 +on f3.card = deck.card3 +and f3.first_round = deck.round group by 1,2 order by 1 desc, prelim_group,2) select * from summary order by round desc,final_score desc,prelim_score desc,prelim_group,player; diff --git a/templates/index.html b/templates/index.html @@ -15,7 +15,8 @@ tr:hover {background-color: #ddd;} </head> <body> <h1>3 Card Blind Data Analysis</h1> - Full, cleaned data for <a href="//3cardmagic.org">3 card blind metashape</a>. Source code can be found <a href="//git.alexw.nyc/3cardblind">here</a>. <a href="export.tsv">Download</a> an export as tsv-formatted data. + Full, cleaned data for <a href="//3cardmagic.org">3 card blind metashape</a>. Source code can be found <a href="//git.alexw.nyc/3cardblind">here</a>. <a href="export.tsv">Download</a> an export as tsv-formatted data.<br> + <b>Bold</b> represents that that round is the first time this card was played. <p>Click on a header to sort by that value.</p> <table class="sortable"> <th><td>player</td><td>card 1</td><td>card 2</td> @@ -26,10 +27,12 @@ tr:hover {background-color: #ddd;} <td>{{deck.round}}</td> <td>{{deck.player}}</td> {% set cards = [deck.card1, deck.card2, deck.card3] %} - {% for card in cards %} + {% set new = [deck.card1new, deck.card2new, deck.card3new] %} + {% for card, new in cards|zip(new) %} <td> <div class="hover_img"> - <a href="https://scryfall.com/search?q={{card}}">{{card}} + <a href="https://scryfall.com/search?q={{card}}"> + {% if new %}<b>{{card}}</b>{% else %}{{card}}{% endif %} <span> <img loading=lazy src="https://api.scryfall.com/cards/named?exact={{card}}&format=image&version=small" /></span></a> </div>