hardcoded updates

This commit is contained in:
buenosairesam
2025-05-08 22:58:56 -03:00
parent 706ed2039c
commit 0b9f23fafd
4 changed files with 18 additions and 32 deletions

View File

@@ -2,13 +2,7 @@ from datetime import datetime, timedelta
from flask import Blueprint, render_template from flask import Blueprint, render_template
from .get_period_times import ( from .get_period_times import get_period_totals, task_or_none, timezone
get_period_totals,
read_and_extract,
task_file,
task_or_none,
timezone,
)
dmbp = Blueprint("deskmeter", __name__, url_prefix="/", template_folder="templates") dmbp = Blueprint("deskmeter", __name__, url_prefix="/", template_folder="templates")
@@ -43,11 +37,11 @@ def oneday(
): ):
task = task_or_none(task) task = task_or_none(task)
start = datetime(2020, month, day).replace( start = datetime(2025, month, day).replace(
hour=0, minute=0, second=0, tzinfo=timezone hour=0, minute=0, second=0, tzinfo=timezone
) )
end = datetime(2020, month, day).replace( end = datetime(2025, month, day).replace(
hour=23, minute=59, second=59, tzinfo=timezone hour=23, minute=59, second=59, tzinfo=timezone
) )
@@ -72,23 +66,18 @@ def period(start, end):
@dmbp.route("/totals") @dmbp.route("/totals")
def totals(): @dmbp.route("/totals/<string:task>")
def totals(task=None):
""" """
Show total time used in each desktop for all time Show total time used in each desktop for all time
""" """
pipe = [ task = task_or_none(task)
{"$group": {"_id": "$workspace", "totals": {"$sum": "$delta"}}},
{"$sort": {"_id": 1}},
]
rows = [] start = datetime(2020, 1, 1).replace(hour=0, minute=0, second=0, tzinfo=timezone)
for total in switches.aggregate(pipeline=pipe):
rows.append( end = datetime(2030, 1, 1).replace(hour=23, minute=59, second=59, tzinfo=timezone)
{
"ws": total["_id"], rows = get_period_totals(start, end)
"total": str(timedelta(seconds=total["totals"])),
}
)
return render_template("pages.html", rows=rows) return render_template("pages.html", rows=rows)

View File

@@ -30,17 +30,17 @@ def now():
return datetime.now(timezone) return datetime.now(timezone)
def convert_seconds(seconds): def convert_seconds(seconds, use_days=False):
days = seconds // 86400 # 86400 seconds in a day days = seconds // 86400
hours = (seconds % 86400) // 3600 hours = (seconds % 86400) // 3600
minutes = (seconds % 3600) // 60 minutes = (seconds % 3600) // 60
remaining_seconds = seconds % 60 remaining_seconds = seconds % 60
if days > 0:
if use_days:
return "{} days, {:02d}:{:02d}:{:02d}".format( return "{} days, {:02d}:{:02d}:{:02d}".format(
days, hours, minutes, remaining_seconds days, hours, minutes, remaining_seconds
) )
else: return "{:02d}:{:02d}:{:02d}".format(hours + days * 24, minutes, remaining_seconds)
return "{:02d}:{:02d}:{:02d}".format(hours, minutes, remaining_seconds)
def extract(line): def extract(line):

View File

@@ -2,5 +2,4 @@
from dmweb import create_app from dmweb import create_app
app = create_app() app = create_app()
app.run(host='0.0.0.0', debug=True, threaded=True) app.run(host="0.0.0.0", debug=True, threaded=True, port=10000)

View File

@@ -19,7 +19,7 @@ switches = db.switch
dailies = db.daily dailies = db.daily
desktops = ("Plan", "Think", "Work", "Other", "Away") desktops = ("Plan", "Think", "Work", "Other", "Away", "Work", "Work")
task_file = "/home/mariano/LETRAS/org/task/main" task_file = "/home/mariano/LETRAS/org/task/main"
@@ -101,9 +101,7 @@ while True:
{"_id": last_doc["_id"]}, {"$set": {"delta": delta, "task": current_task}} {"_id": last_doc["_id"]}, {"$set": {"delta": delta, "task": current_task}}
) )
else: else:
time.sleep(2)
current_workspace = active_workspace() current_workspace = active_workspace()
switch = { switch = {
"workspace": desktop(current_workspace), "workspace": desktop(current_workspace),
"date": now(), "date": now(),