diff --git a/web/app.py b/web/app.py index f125784..ab8d02e 100644 --- a/web/app.py +++ b/web/app.py @@ -43,41 +43,41 @@ def i404(): @app.route('/') def index(): conn = get_db_connection() - users = conn.execute('SELECT id, username FROM users').fetchall() - top_users = conn.execute(''' - SELECT users.id, users.username, COUNT(pulls.id) AS pull_count - FROM users - LEFT JOIN pulls ON users.id = pulls.user_id - GROUP BY users.id + players = conn.execute('SELECT id, username FROM players').fetchall() + top_players = conn.execute(''' + SELECT players.id, players.username, COUNT(pulls.id) AS pull_count + FROM players + LEFT JOIN pulls ON players.id = pulls.player_id + GROUP BY players.id ORDER BY pull_count DESC LIMIT 5 ''').fetchall() conn.close() - return render_template('index.html', users=users, top_users=top_users) + return render_template('index.html', players=players, top_players=top_players) -@app.route('/user/') -def user_profile(user_id): +@app.route('/player/') +def player_profile(id): conn = get_db_connection() conn.row_factory = sqlite3.Row cursor = conn.cursor() - cursor.execute('SELECT * FROM users WHERE id = ?', (user_id,)) - user = cursor.fetchone() - if user is None: + cursor.execute('SELECT * FROM players WHERE id = ?', (id,)) + player = cursor.fetchone() + if player is None: abort(404) cursor.execute(''' - SELECT pulls.timestamp, characters.name as character_name, characters.rarity + SELECT pulls.timestamp, cards.name as card_name, cards.rarity FROM pulls - JOIN characters ON pulls.character_id = characters.id - WHERE pulls.user_id = ? + JOIN cards ON pulls.card_id = cards.id + WHERE pulls.player_id = ? ORDER BY pulls.timestamp DESC - ''', (user_id,)) + ''', (id,)) pulls = cursor.fetchall() conn.close() - return render_template('user.html', user=user, pulls=pulls) + return render_template('player.html', player=player, pulls=pulls) @app.route('/about') def about(): diff --git a/web/templates/index.html b/web/templates/index.html index 6f2351d..a39144d 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -19,27 +19,21 @@ along with this program. If not, see https://www.gnu.org/licenses/. {% extends "_base.html" %} {% block header %} -

Misskey Gacha Center

+

Kemoverse

Track your luck. Compare your pulls. Compete with friends.

{% endblock %} {% block content %}

🎖️ Leaderboard: Most Rolls

- {% for user in top_users %} + {% for player in top_players %}
- {{ loop.index }}. {{ user['username'] }} — {{ user['pull_count'] }} rolls + {{ loop.index }}. {{ player['username'] }} — {{ player['pull_count'] }} rolls
{% else %}

No pulls yet. Be the first to roll!

{% endfor %} -

📋 All Registered Users

-
🚀 This is a fun little gacha tracker! More features coming soon. Want to help shape it? diff --git a/web/templates/user.html b/web/templates/player.html similarity index 84% rename from web/templates/user.html rename to web/templates/player.html index 1ccb447..b37971e 100644 --- a/web/templates/user.html +++ b/web/templates/player.html @@ -18,8 +18,8 @@ along with this program. If not, see https://www.gnu.org/licenses/. {% extends "_base.html" %} {% block content %}
-

{{ user['username'] }}'s Gacha Rolls

-

User ID: {{ user['id'] }}

+

{{ player['username'] }}'s Gacha Rolls

+

Player ID: {{ player['id'] }}

Total Rolls: {{ pulls | length }}

@@ -29,12 +29,12 @@ along with this program. If not, see https://www.gnu.org/licenses/. {% for pull in pulls %}
  • {{ pull['timestamp'] }}
    - {{ pull['character_name'] }} + {{ pull['card_name'] }} {{ '★' * pull['rarity'] }}
  • {% endfor %}
    - ← Back to Users + ← Back to Home {% endblock %} \ No newline at end of file