Commit 4760d327 authored by Administrator's avatar Administrator

bugfix: check for non persisted records

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