feat: build Stride local app with Garmin imports and friends-only sharing
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
"""Disposable UI fixture on port 5001. Synthetic friend-shared data; never reads Garmin files."""
|
||||
|
||||
import math
|
||||
import sys
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
|
||||
from waitress import serve
|
||||
|
||||
from app import create_app
|
||||
from app.extensions import db
|
||||
from app.models import Activity, User
|
||||
|
||||
app = create_app(
|
||||
{
|
||||
"SQLALCHEMY_DATABASE_URI": "sqlite://",
|
||||
"SECRET_KEY": "disposable-ui-fixture",
|
||||
"LOCAL_SETUP": False,
|
||||
"RATELIMIT_ENABLED": False,
|
||||
}
|
||||
)
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
user = User(
|
||||
username="preview",
|
||||
display_name="Preview Runner",
|
||||
email="preview@example.test",
|
||||
password_hash="disabled",
|
||||
)
|
||||
db.session.add(user)
|
||||
db.session.flush()
|
||||
for i in range(5):
|
||||
samples = [
|
||||
{
|
||||
"point": [51.507 + 0.007 * math.sin(n / 70), -0.14 + n / 25000],
|
||||
"distance": n * 20,
|
||||
"speed": 2.8 + 0.3 * math.sin(n / 20),
|
||||
"heart_rate": 140 + 12 * math.sin(n / 30),
|
||||
"elevation": 10 + n / 30,
|
||||
}
|
||||
for n in range(300)
|
||||
]
|
||||
db.session.add(
|
||||
Activity(
|
||||
owner_id=user.id,
|
||||
source_key=f"fixture:{i}",
|
||||
title=[
|
||||
"Morning miles",
|
||||
"A little further",
|
||||
"Easy Sunday",
|
||||
"Tempo session",
|
||||
"Evening loop",
|
||||
][i],
|
||||
started_at=datetime.now(UTC) - timedelta(days=i * 5),
|
||||
distance_m=6000 + i * 700,
|
||||
duration_s=2100 + i * 200,
|
||||
elevation_m=38 + i * 7,
|
||||
avg_hr=145,
|
||||
sport="running",
|
||||
visibility="friends",
|
||||
samples=samples,
|
||||
laps=[{"distance": 1000, "duration": 350, "pace": 350, "heart_rate": 145}] * 6,
|
||||
)
|
||||
)
|
||||
db.session.commit()
|
||||
|
||||
# Test-only auto-login, isolated to this ephemeral process/database.
|
||||
from flask_login import login_user
|
||||
|
||||
|
||||
@app.before_request
|
||||
def preview_login():
|
||||
login_user(db.session.get(User, 1))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
serve(app, host="127.0.0.1", port=5001)
|
||||
Reference in New Issue
Block a user