WIP reporting on actions taken

This commit is contained in:
2026-06-16 09:15:18 -04:00
parent b2f84a27cd
commit bc3e178676
2 changed files with 15 additions and 3 deletions

10
app.py
View File

@@ -94,6 +94,7 @@ def generate_report(user_id, begin_date, end_date):
conn.close() conn.close()
total_seconds = 0 total_seconds = 0
paid_seconds = 0 paid_seconds = 0
actions = []
for row in rows: for row in rows:
timestamp = parse_iso_datetime(row["ts"]) timestamp = parse_iso_datetime(row["ts"])
if timestamp < begin_dt or timestamp > end_dt: if timestamp < begin_dt or timestamp > end_dt:
@@ -103,9 +104,11 @@ def generate_report(user_id, begin_date, end_date):
paid_seconds += delta.total_seconds() paid_seconds += delta.total_seconds()
else: else:
total_seconds += delta.total_seconds() total_seconds += delta.total_seconds()
if row["comments"]:
actions.append(row["comments"])
total_hours = total_seconds / 3600.0 total_hours = total_seconds / 3600.0
paid_hours = paid_seconds / 3600.0 paid_hours = paid_seconds / 3600.0
return round(total_hours, 2), round(paid_hours, 2) return round(total_hours, 2), round(paid_hours, 2), actions
@app.route("/", methods=["GET", "POST"]) @app.route("/", methods=["GET", "POST"])
def index(): def index():
@@ -176,7 +179,7 @@ def index():
elif action == "report": elif action == "report":
begin_date = request.form.get("begin_date") begin_date = request.form.get("begin_date")
end_date = request.form.get("end_date") end_date = request.form.get("end_date")
report_hours = generate_report( report_hours, paid_hours, actions = generate_report(
selected_user_id, selected_user_id,
begin_date, begin_date,
end_date end_date
@@ -194,7 +197,8 @@ def index():
"id": user["id"], "id": user["id"],
"name": user["name"], "name": user["name"],
"total_hours": total_hours, "total_hours": total_hours,
"paid_hours": paid_hours "paid_hours": paid_hours,
"actions": actions
}) })
return render_template( return render_template(
"index.html", "index.html",

View File

@@ -39,6 +39,7 @@
<th>User</th> <th>User</th>
<th>Total Hours Worked</th> <th>Total Hours Worked</th>
<th>Paid Hours</th> <th>Paid Hours</th>
<th>Actions</th>
</tr> </tr>
{% for report in all_user_reports %} {% for report in all_user_reports %}
@@ -46,6 +47,13 @@
<td>{{ report.name }}</td> <td>{{ report.name }}</td>
<td>{{ report.total_hours }}</td> <td>{{ report.total_hours }}</td>
<td>{{ report.paid_hours }}</td> <td>{{ report.paid_hours }}</td>
<td>
<ul>
{% for action in report.actions %}
<li>{{ action }}</li>
{% endfor %}
</ul>
</td>
</tr> </tr>
{% endfor %} {% endfor %}