WIP reporting on actions taken
This commit is contained in:
10
app.py
10
app.py
@@ -94,6 +94,7 @@ def generate_report(user_id, begin_date, end_date):
|
||||
conn.close()
|
||||
total_seconds = 0
|
||||
paid_seconds = 0
|
||||
actions = []
|
||||
for row in rows:
|
||||
timestamp = parse_iso_datetime(row["ts"])
|
||||
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()
|
||||
else:
|
||||
total_seconds += delta.total_seconds()
|
||||
if row["comments"]:
|
||||
actions.append(row["comments"])
|
||||
total_hours = total_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"])
|
||||
def index():
|
||||
@@ -176,7 +179,7 @@ def index():
|
||||
elif action == "report":
|
||||
begin_date = request.form.get("begin_date")
|
||||
end_date = request.form.get("end_date")
|
||||
report_hours = generate_report(
|
||||
report_hours, paid_hours, actions = generate_report(
|
||||
selected_user_id,
|
||||
begin_date,
|
||||
end_date
|
||||
@@ -194,7 +197,8 @@ def index():
|
||||
"id": user["id"],
|
||||
"name": user["name"],
|
||||
"total_hours": total_hours,
|
||||
"paid_hours": paid_hours
|
||||
"paid_hours": paid_hours,
|
||||
"actions": actions
|
||||
})
|
||||
return render_template(
|
||||
"index.html",
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
<th>User</th>
|
||||
<th>Total Hours Worked</th>
|
||||
<th>Paid Hours</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
|
||||
{% for report in all_user_reports %}
|
||||
@@ -46,6 +47,13 @@
|
||||
<td>{{ report.name }}</td>
|
||||
<td>{{ report.total_hours }}</td>
|
||||
<td>{{ report.paid_hours }}</td>
|
||||
<td>
|
||||
<ul>
|
||||
{% for action in report.actions %}
|
||||
<li>{{ action }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user