From 68b8588c766afd5589d4f26ebafd9db91c270a3c Mon Sep 17 00:00:00 2001 From: Lili Date: Tue, 14 Mar 2023 15:42:14 +0100 Subject: [PATCH] dashboard milestones stub --- tlapbot/owncast_helpers.py | 10 +++ tlapbot/owncast_redeem_dashboard.py | 3 +- tlapbot/templates/dashboard.html | 97 +++++++++++++++++------------ 3 files changed, 69 insertions(+), 41 deletions(-) diff --git a/tlapbot/owncast_helpers.py b/tlapbot/owncast_helpers.py index fd77351..7ad649f 100644 --- a/tlapbot/owncast_helpers.py +++ b/tlapbot/owncast_helpers.py @@ -208,6 +208,16 @@ def add_to_milestone(db, redeem_name, points): return False +def all_milestones(db): + try: + cursor = db.execute( + """SELECT name, count, goal FROM milestones""" + ) + return cursor.fetchall() + except Error as e: + current_app.logger.error(f"Error occured selecting all milestones: {e.args[0]}") + + def all_counters(db): try: cursor = db.execute( diff --git a/tlapbot/owncast_redeem_dashboard.py b/tlapbot/owncast_redeem_dashboard.py index ce29742..fcfc298 100644 --- a/tlapbot/owncast_redeem_dashboard.py +++ b/tlapbot/owncast_redeem_dashboard.py @@ -1,7 +1,7 @@ from flask import render_template, Blueprint, request, current_app from tlapbot.db import get_db from tlapbot.owncast_helpers import (pretty_redeem_queue, all_counters, - read_all_users_with_username) + all_milestones, read_all_users_with_username) from datetime import datetime, timezone bp = Blueprint('redeem_dashboard', __name__) @@ -19,6 +19,7 @@ def dashboard(): return render_template('dashboard.html', queue=pretty_redeem_queue(db), counters=all_counters(db), + milestones=all_milestones(db), redeems=current_app.config['REDEEMS'], prefix=current_app.config['PREFIX'], passive=current_app.config['PASSIVE'], diff --git a/tlapbot/templates/dashboard.html b/tlapbot/templates/dashboard.html index da7e36a..a501629 100644 --- a/tlapbot/templates/dashboard.html +++ b/tlapbot/templates/dashboard.html @@ -11,6 +11,9 @@
{% if not passive %} + {% if queue %} + + {% endif %} {% endif %}
@@ -40,47 +43,59 @@ {% endif %} {% if not passive %} - {% if counters %} - - - - - - - {% for counter in counters %} - - - - - {% endfor %} -
Active counters
{{ counter[0] }} {{ counter[1] }}
- {% endif %} - - {% if queue %} - - - - - - - - - - - - - {% for row in queue %} + {% if counters %} +
Recent redeems
TimeRedeemRedeemerNote
+ + + + + + {% for counter in counters %} - - - - {% if row[2] %} - - {% endif %} - - {% endfor %} -
Active counters
{{ row[0].replace(tzinfo=utc_timezone).astimezone().strftime("%H:%M") }}{{ row[1] }}{{ row[3] }}{{ row[2] }}
- {% endif %} + {{ counter[0] }} + {{ counter[1] }} + + {% endfor %} + + {% endif %} + {% if milestones %} + {% for milestone in milestones %} + + + + {% endfor %} + {% endif %} + {% endif %} + + + +
+ +

Redeems Queue

+ {% if queue %} + + + + + + + + + + + + + {% for row in queue %} + + + + + {% if row[2] %} + + {% endif %} + + {% endfor %} +
Recent redeems
TimeRedeemRedeemerNote
{{ row[0].replace(tzinfo=utc_timezone).astimezone().strftime("%H:%M") }}{{ row[1] }}{{ row[3] }}{{ row[2] }}
{% endif %}
@@ -92,6 +107,8 @@
  • Counter redeems add +1 to their counter.
  • List redeems get added to the list of recent redeems (without a note).
  • Note redeems require you to send a message together with the redeem.
  • +
  • Milestone redeems are long-term goals to which you can donate any amount of points you want.
  • +
  • They will be completed once the amount of points donated reaches the goal.
  • {% if redeems %}