commit 40b757f3d9a9f5a36ec245a76b78ad53556c9dd7
parent 7de02419283bdfcd444b533149e91a3eaf455d6e
Author: alex wennerberg <alex@alexwennerberg.com>
Date: Thu, 27 Nov 2025 16:34:58 -0500
junkola
Diffstat:
6 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/app.py b/app.py
@@ -92,6 +92,21 @@ def banned():
subtitle = "banned cards"
return render_template('banned.html', banned_cards=banned_cards, subtitle=subtitle)
+@app.route('/cards')
+def cards():
+ db = get_db()
+ cards = db.execute("""
+ SELECT card, COUNT(*) as play_count
+ FROM card
+ WHERE card IS NOT NULL
+ GROUP BY card
+ ORDER BY play_count DESC, card ASC
+ """).fetchall()
+ banned_cards = [row["name"] for row in db.execute("select name from ban").fetchall()]
+ db.close()
+ subtitle = "all cards"
+ return render_template('cards.html', cards=cards, banned_cards=banned_cards, subtitle=subtitle)
+
# Template filter for url encoding
@app.template_filter('url_encode')
def url_encode_filter(s):
diff --git a/deploy.sh b/deploy.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-REMOTE_HOST="pi"
+REMOTE_HOST="192.168.1.214"
REMOTE_USER="root"
git ls-files > /tmp/git_files_list
diff --git a/runround.sh b/runround.sh
@@ -2,5 +2,5 @@ sqlite3 3cb.db < sql/delete-last.sql
source .venv/bin/activate
python getdata.py
sqlite3 3cb.db < sql/new.sql
-scp 3cb.db root@pi:/opt/3cardblind/3cb.db
-ssh root@pi "rc-service 3cardblind restart"
+scp 3cb.db root@192.168.1.214:/opt/3cardblind/3cb.db
+ssh root@192.168.1.214 "rc-service 3cardblind restart"
diff --git a/sql/new.sql b/sql/new.sql
@@ -27,5 +27,4 @@ select min(card.round) as rnd, group_name = 'final' as isfinal, card
from match join card on match.round = card.round and match.player = card.player
group by 2,3 order by 1,2)
select card from new where rnd = (select max(rnd) from new) and isfinal;
-
-
+select 'Data at https://data.3cardmagic.org'
diff --git a/templates/cards.html b/templates/cards.html
@@ -0,0 +1,18 @@
+{% include 'header.html' %}
+<table class="cards-table">
+ <thead>
+ <tr>
+ <th>Card</th>
+ <th>Play Count</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for card in cards %}
+ <tr>
+ <td><a href="/card?name={{ card.card|url_encode }}">{{ card.card }}</a>{% if card.card in banned_cards %} <span style="color: red;">(banned)</span>{% endif %}</td>
+ <td>{{ card.play_count }}</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+</table>
+{% include 'footer.html' %}
+\ No newline at end of file
diff --git a/templates/index.html b/templates/index.html
@@ -1,5 +1,5 @@
{% include 'header.html' %}
-<p><a href="/players">View all players</a> | <a href="/banned">View banned cards</a></p>
+<p><a href="/players">View all players</a> | <a href="/banned">View banned cards</a> | <a href="/cards">View all cards</a></p>
<form action="/card" method="get" class="card-search">
<input type="text" name="name" placeholder="Search for a card..." required>
<input type="submit" value="Search">