Change readings table to list of cards, also update edit reading page to include link to delete reading
This commit is contained in:
@@ -2,6 +2,7 @@ import csv
|
||||
from io import StringIO
|
||||
import io
|
||||
from flask import Blueprint, Response, make_response, render_template, redirect, request, send_file, url_for, flash
|
||||
import humanize
|
||||
from sqlalchemy import func
|
||||
from werkzeug.security import generate_password_hash, check_password_hash
|
||||
from werkzeug.http import http_date
|
||||
@@ -104,6 +105,12 @@ def dashboard():
|
||||
# Fetch and order readings
|
||||
readings = readings_query.order_by(Reading.timestamp.desc()).all()
|
||||
|
||||
# Add human-readable relative timestamps to readings
|
||||
now = datetime.utcnow()
|
||||
for reading in readings:
|
||||
reading.relative_timestamp = humanize.naturaltime(now - reading.timestamp)
|
||||
|
||||
|
||||
# Weekly summary (last 7 days)
|
||||
one_week_ago = datetime.now() - timedelta(days=7)
|
||||
weekly_readings = [r for r in readings if r.timestamp >= one_week_ago]
|
||||
|
||||
Reference in New Issue
Block a user