Commit 76cdabf1 authored by Administrator's avatar Administrator

trigger episode download, but: High download request numbers

parent 9c21f513
......@@ -43,7 +43,7 @@ class Activity extends Model {
static Activity of(BuildContext context) => ScopedModel.of<Activity>(context);
queryStrava() async {
static queryStrava() async {
Strava strava = Strava(true, secret);
final prompt = 'auto';
......@@ -57,13 +57,14 @@ class Activity extends Model {
.now()
.microsecondsSinceEpoch ~/ 1000;
final yesterday = now - 86400;
final startDate = now - 7 * 86400;
List<SummaryActivity> summaryActivities = await strava
.getLoggedInAthleteActivities(now, yesterday);
.getLoggedInAthleteActivities(now, startDate);
for(SummaryActivity summaryActivity in summaryActivities) {
Activity.fromStrava(summaryActivity).persist();
Activity activity = Activity.fromStrava(summaryActivity);
activity.persist();
}
print("Hello");
......
......@@ -105,21 +105,20 @@ class _DashboardState extends State<Dashboard> {
),
for (DbAthlete athlete in snapshot.data)
ListTile(
leading: Image.network(athlete.photoPath),
title:
Text("${athlete.firstName} ${athlete.lastName}"),
subtitle: Text("${athlete.stravaId}"),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ScopedModel<Athlete>(
model: Athlete(),
child: ListActivitiesScreen(athlete: athlete),
),
leading: Image.network(athlete.photoPath),
title: Text("${athlete.firstName} ${athlete.lastName}"),
subtitle: Text("${athlete.stravaId}"),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ListActivitiesScreen(
athlete: athlete,
),
);
},)
),
);
},
)
],
);
}
......
import 'package:encrateia/models/activity.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/model/model.dart';
......@@ -22,6 +23,7 @@ class _ListActivitiesScreenState extends State<ListActivitiesScreen> {
ListTile(
leading: Icon(Icons.cloud_download),
title: Text("Download Activities from Strava"),
onTap: () {Activity.queryStrava(); },
)
],
),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment