Precompute run analysis and serve compact route previews
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user