WIP: Website overhaul #60

Draft
waifu wants to merge 1 commit from website into dev
3 changed files with 24 additions and 30 deletions

View file

@ -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/<int:user_id>')
def user_profile(user_id):
@app.route('/player/<int:id>')
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():

View file

@ -19,27 +19,21 @@ along with this program. If not, see https://www.gnu.org/licenses/.
{% extends "_base.html" %}
{% block header %}
<h1>Misskey Gacha Center</h1>
<h1>Kemoverse</h1>
<p>Track your luck. Compare your pulls. Compete with friends.</p>
{% endblock %}
{% block content %}
<h2>🎖️ Leaderboard: Most Rolls</h2>
{% for user in top_users %}
{% for player in top_players %}
<div class="leaderboard-entry">
{{ loop.index }}. <strong>{{ user['username'] }}</strong> — {{ user['pull_count'] }} rolls
{{ loop.index }}. <strong>{{ player['username'] }}</strong> — {{ player['pull_count'] }} rolls
</div>
{% else %}
<p>No pulls yet. Be the first to roll!</p>
{% endfor %}
<h2>📋 All Registered Users</h2>
<ul>
{% for user in users %}
<li><a href="{{ url_for('user_profile', user_id=user['id']) }}">{{ user['username'] }}</a></li>
{% endfor %}
</ul>
<div class="note">
🚀 This is a fun little gacha tracker! More features coming soon. Want to help shape it?

View file

@ -18,8 +18,8 @@ along with this program. If not, see https://www.gnu.org/licenses/.
{% extends "_base.html" %}
{% block content %}
<div class="profile">
<h1>{{ user['username'] }}'s Gacha Rolls</h1>
<p>User ID: {{ user['id'] }}</p>
<h1>{{ player['username'] }}'s Gacha Rolls</h1>
<p>Player ID: {{ player['id'] }}</p>
<p>Total Rolls: {{ pulls | length }}</p>
</div>
@ -29,12 +29,12 @@ along with this program. If not, see https://www.gnu.org/licenses/.
{% for pull in pulls %}
<li>
<span class="timestamp">{{ pull['timestamp'] }}</span><br>
{{ pull['character_name'] }}
{{ pull['card_name'] }}
<span class="rarity">{{ '★' * pull['rarity'] }}</span>
</li>
{% endfor %}
</ul>
</div>
<a href="{{ url_for('index') }}">← Back to Users</a>
<a href="{{ url_for('index') }}">← Back to Home</a>
{% endblock %}