Commit 4760d327 authored by Administrator's avatar Administrator

bugfix: check for non persisted records

parent f96d6051
...@@ -53,7 +53,7 @@ class Activity { ...@@ -53,7 +53,7 @@ class Activity {
DbActivity _db; DbActivity _db;
List<Event> _records; List<Event> _records;
List<Lap> cachedLaps; List<Lap> cachedLaps = <Lap>[];
List<Tag> cachedTags = <Tag>[]; List<Tag> cachedTags = <Tag>[];
double glidingMeasureAttribute; double glidingMeasureAttribute;
double weight; double weight;
...@@ -62,6 +62,7 @@ class Activity { ...@@ -62,6 +62,7 @@ class Activity {
HeartRateZone _heartRateZone; HeartRateZone _heartRateZone;
HeartRateZoneSchema _heartRateZoneSchema; HeartRateZoneSchema _heartRateZoneSchema;
int get id => _db?.id;
String get name => _db.name; String get name => _db.name;
DateTime get startTime => _db.startTime; DateTime get startTime => _db.startTime;
int get movingTime => _db.movingTime; int get movingTime => _db.movingTime;
...@@ -125,7 +126,6 @@ class Activity { ...@@ -125,7 +126,6 @@ class Activity {
double get avgGroundTime => _db.avgGroundTime; double get avgGroundTime => _db.avgGroundTime;
double get sdevGroundTime => _db.sdevGroundTime; double get sdevGroundTime => _db.sdevGroundTime;
double get sdevVerticalOscillation => _db.sdevVerticalOscillation; double get sdevVerticalOscillation => _db.sdevVerticalOscillation;
int get id => _db.id;
set name(String value) => _db.name = value; set name(String value) => _db.name = value;
set state(String value) => _db.state = value; set state(String value) => _db.state = value;
...@@ -258,7 +258,7 @@ class Activity { ...@@ -258,7 +258,7 @@ class Activity {
String paceString() => avgSpeed.toPace() + '/km'; String paceString() => avgSpeed.toPace() + '/km';
Future<List<Event>> get records async { Future<List<Event>> get records async {
return _records ??= await Event.recordsByActivity(activity: this); return _records ??= await Event.recordsByActivity(this);
} }
Future<List<Tag>> get tags async { Future<List<Tag>> get tags async {
......
...@@ -20,6 +20,7 @@ class ActivityTagging { ...@@ -20,6 +20,7 @@ class ActivityTagging {
DbActivityTagging _db; DbActivityTagging _db;
int get id => _db?.id;
int get activitiesId => _db.activitiesId; int get activitiesId => _db.activitiesId;
int get tagsId => _db.tagsId; int get tagsId => _db.tagsId;
......
...@@ -27,7 +27,7 @@ class Athlete { ...@@ -27,7 +27,7 @@ class Athlete {
DbAthlete _db = DbAthlete(); DbAthlete _db = DbAthlete();
List<int> filters = <int>[]; List<int> filters = <int>[];
int get id => _db.id; int get id => _db?.id;
String get firstName => _db.firstName; String get firstName => _db.firstName;
String get lastName => _db.lastName; String get lastName => _db.lastName;
int get stravaId => _db.stravaId; int get stravaId => _db.stravaId;
......
...@@ -101,7 +101,7 @@ class Event { ...@@ -101,7 +101,7 @@ class Event {
Lap lap; Lap lap;
int index; int index;
int get id => _db.id; int get id => _db?.id;
String get event => _db.event; String get event => _db.event;
int get power => _db.power; int get power => _db.power;
int get heartRate => _db.heartRate; int get heartRate => _db.heartRate;
...@@ -120,21 +120,21 @@ class Event { ...@@ -120,21 +120,21 @@ class Event {
@override @override
String toString() => '< Event | $event | $index >'; String toString() => '< Event | $event | $index >';
static Future<List<Event>> recordsByLap({Lap lap}) async { static Future<List<Event>> recordsByLap(Lap lap) async {
final List<Event> events = await byLap(lap: lap); final List<Event> events = await byLap(lap);
final Iterable<Event> records = final Iterable<Event> records =
events.where((Event event) => event.event == 'record'); events.where((Event event) => event.event == 'record');
return records.toList(); return records.toList();
} }
static Future<List<Event>> recordsByActivity({Activity activity}) async { static Future<List<Event>> recordsByActivity(Activity activity) async {
final List<Event> events = await by(activity: activity); final List<Event> events = await byActivity(activity);
final Iterable<Event> records = final Iterable<Event> records =
events.where((Event event) => event.event == 'record'); events.where((Event event) => event.event == 'record');
return records.toList(); return records.toList();
} }
static Future<List<Event>> byLap({Lap lap}) async { static Future<List<Event>> byLap(Lap lap) async {
int counter = 1; int counter = 1;
final List<Event> events = await lap.events; final List<Event> events = await lap.events;
...@@ -147,7 +147,7 @@ class Event { ...@@ -147,7 +147,7 @@ class Event {
return events; return events;
} }
static Future<List<Event>> by({Activity activity}) async { static Future<List<Event>> byActivity(Activity activity) async {
int counter = 1; int counter = 1;
final List<Event> events = await activity.events; final List<Event> events = await activity.events;
...@@ -167,5 +167,5 @@ class Event { ...@@ -167,5 +167,5 @@ class Event {
.toList()); .toList());
} }
static Event exDb(DbEvent db) => Event._fromDb(db); static Event exDb(DbEvent dbEvent) => Event._fromDb(dbEvent);
} }
...@@ -30,7 +30,7 @@ class HeartRateZone { ...@@ -30,7 +30,7 @@ class HeartRateZone {
DbHeartRateZone _db; DbHeartRateZone _db;
int get id => _db.id; int get id => _db?.id;
int get color => _db.color; int get color => _db.color;
String get name => _db.name; String get name => _db.name;
int get lowerLimit => _db.lowerLimit; int get lowerLimit => _db.lowerLimit;
......
...@@ -33,7 +33,7 @@ class HeartRateZoneSchema { ...@@ -33,7 +33,7 @@ class HeartRateZoneSchema {
DbHeartRateZoneSchema _db; DbHeartRateZoneSchema _db;
int get id => _db.id; int get id => _db?.id;
String get name => _db.name; String get name => _db.name;
DateTime get date => _db.date; DateTime get date => _db.date;
int get base => _db.base; int get base => _db.base;
......
...@@ -35,7 +35,7 @@ class Lap { ...@@ -35,7 +35,7 @@ class Lap {
List<BarZone> powerDistributions; List<BarZone> powerDistributions;
List<BarZone> heartRateDistributions; List<BarZone> heartRateDistributions;
int get id => _db.id; int get id => _db?.id;
int get activitiesId => _db.activitiesId; int get activitiesId => _db.activitiesId;
int get avgHeartRate => _db.avgHeartRate; int get avgHeartRate => _db.avgHeartRate;
int get totalDistance => _db.totalDistance; int get totalDistance => _db.totalDistance;
...@@ -134,7 +134,7 @@ class Lap { ...@@ -134,7 +134,7 @@ class Lap {
} }
Future<List<Event>> get records async { Future<List<Event>> get records async {
_records ??= await Event.recordsByLap(lap: this); _records ??= await Event.recordsByLap(this);
return _records; return _records;
} }
......
...@@ -20,6 +20,7 @@ class LapTagging { ...@@ -20,6 +20,7 @@ class LapTagging {
DbLapTagging _db; DbLapTagging _db;
int get id => _db?.id;
int get lapsId => _db.lapsId; int get lapsId => _db.lapsId;
int get tagsId => _db.tagsId; int get tagsId => _db.tagsId;
......
...@@ -31,7 +31,7 @@ class PowerZone { ...@@ -31,7 +31,7 @@ class PowerZone {
DbPowerZone _db; DbPowerZone _db;
int get id => _db.id; int get id => _db?.id;
int get color => _db.color; int get color => _db.color;
String get name => _db.name; String get name => _db.name;
int get lowerLimit => _db.lowerLimit; int get lowerLimit => _db.lowerLimit;
......
...@@ -41,7 +41,7 @@ class PowerZoneSchema { ...@@ -41,7 +41,7 @@ class PowerZoneSchema {
DbPowerZoneSchema _db; DbPowerZoneSchema _db;
int get id => _db.id; int get id => _db?.id;
String get name => _db.name; String get name => _db.name;
DateTime get date => _db.date; DateTime get date => _db.date;
int get base => _db.base; int get base => _db.base;
......
...@@ -24,7 +24,7 @@ class Tag { ...@@ -24,7 +24,7 @@ class Tag {
DbTag _db; DbTag _db;
bool selected = false; bool selected = false;
int get id => _db.id; int get id => _db?.id;
int get color => _db.color; int get color => _db.color;
String get name => _db.name; String get name => _db.name;
bool get system => _db.system; bool get system => _db.system;
......
...@@ -34,7 +34,7 @@ class TagGroup { ...@@ -34,7 +34,7 @@ class TagGroup {
DbTagGroup _db; DbTagGroup _db;
List<Tag> cachedTags; List<Tag> cachedTags;
int get id => _db.id; int get id => _db?.id;
int get color => _db.color; int get color => _db.color;
String get name => _db.name; String get name => _db.name;
bool get system => _db.system; bool get system => _db.system;
......
...@@ -14,7 +14,7 @@ class Weight { ...@@ -14,7 +14,7 @@ class Weight {
DbWeight _db; DbWeight _db;
int get id => _db.id; int get id => _db?.id;
DateTime get date => _db.date; DateTime get date => _db.date;
double get value => _db.value; double get value => _db.value;
set date(DateTime value) => _db.date = value; set date(DateTime value) => _db.date = value;
......
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