Precompute run analysis and serve compact route previews

This commit is contained in:
Peter Stockings
2026-10-02 14:19:47 +10:00
parent 2d7069c12d
commit 6bfab483d4
13 changed files with 518 additions and 56 deletions
+7
View File
@@ -10,8 +10,10 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from waitress import serve
from app import create_app
from app.display import persist_analysis
from app.extensions import db
from app.models import Activity, User
from app.records import persist_efforts
app = create_app(
{
@@ -36,6 +38,7 @@ with app.app_context():
{
"point": [51.507 + 0.007 * math.sin(n / 70), -0.14 + n / 25000],
"distance": n * 20,
"time": n * 5,
"speed": 2.8 + 0.3 * math.sin(n / 20),
"heart_rate": 140 + 12 * math.sin(n / 30),
"elevation": 10 + n / 30,
@@ -64,6 +67,10 @@ with app.app_context():
laps=[{"distance": 1000, "duration": 350, "pace": 350, "heart_rate": 145}] * 6,
)
)
for row in list(db.session.new):
if isinstance(row, Activity):
persist_efforts(row)
persist_analysis(row)
db.session.commit()
# Test-only auto-login, isolated to this ephemeral process/database.