unmodified changes from long ago commited to kickstart deskmeter again

This commit is contained in:
buenosairesam
2025-12-19 02:57:39 -03:00
parent a966623c75
commit 58348eab82
4 changed files with 70 additions and 50 deletions

View File

@@ -1,6 +1,6 @@
from datetime import datetime, timedelta
from flask import Blueprint, render_template
from flask import Blueprint, render_template, jsonify
from .get_period_times import get_period_totals, task_or_none, timezone, get_work_period_totals, get_current_task_info, convert_seconds, get_task_time_seconds
@@ -33,11 +33,33 @@ def index(task=None):
if total_seconds > 0:
current_task_time = convert_seconds(total_seconds)
print(rows)
return render_template("main.html", rows=rows, current_task_path=current_task_path, current_task_time=current_task_time, auto_refresh=True)
@dmbp.route("/api/today")
@dmbp.route("/api/today/<string:task>")
def api_today(task=None):
"""
HTML fragment API endpoint for today's data (for AJAX updates)
"""
task = task_or_none(task)
start = datetime.today().replace(hour=0, minute=0, second=0, tzinfo=timezone)
end = datetime.today().replace(hour=23, minute=59, second=59, tzinfo=timezone)
rows = get_period_totals(start, end, task)
# Get current task info
current_task_id, current_task_path = get_current_task_info()
current_task_time = None
if current_task_id:
total_seconds = get_task_time_seconds(start, end, current_task_id)
if total_seconds > 0:
current_task_time = convert_seconds(total_seconds)
return render_template("main_content.html", rows=rows, current_task_path=current_task_path, current_task_time=current_task_time)
@dmbp.route("/day/<int:month>/<int:day>")
@dmbp.route("/day/<string:task>/<int:month>/<int:day>")
def oneday(
@@ -84,7 +106,6 @@ def work():
end = datetime.today().replace(hour=23, minute=59, second=59, tzinfo=timezone)
rows = get_work_period_totals(start, end)
print(rows)
return render_template("main.html", rows=rows, auto_refresh=False)