Commit 0eed826d authored by Administrator's avatar Administrator

started to store laps in db

parent 21849d30
......@@ -88,6 +88,59 @@ const tableEvent = SqfEntityTable(
],
);
const tableLap = SqfEntityTable(
tableName: 'laps',
primaryKeyName: 'id',
primaryKeyType: PrimaryKeyType.integer_auto_incremental,
useSoftDeleting: false,
modelName: 'DbLap',
fields: [
SqfEntityField('timeStamp', DbType.datetime),
SqfEntityField('startTime', DbType.datetime),
SqfEntityField('startPositionLat', DbType.real),
SqfEntityField('startPositionLong', DbType.real),
SqfEntityField('endPositionLat', DbType.real),
SqfEntityField('endPositionLong', DbType.real),
SqfEntityField('avgHeartRate', DbType.integer),
SqfEntityField('maxHeartRate', DbType.integer),
SqfEntityField('avgRunningCadence', DbType.real),
SqfEntityField('event', DbType.text),
SqfEntityField('eventType', DbType.text),
SqfEntityField('eventGroup', DbType.integer),
SqfEntityField('sport', DbType.text),
SqfEntityField('subSport', DbType.text),
SqfEntityField('avgVerticalOscillation', DbType.real),
SqfEntityField('totalElapsedTime', DbType.integer),
SqfEntityField('totalTimerTime', DbType.integer),
SqfEntityField('totalDistance', DbType.integer),
SqfEntityField('totalStrides', DbType.integer),
SqfEntityField('totalCalories', DbType.integer),
SqfEntityField('avgSpeed', DbType.real),
SqfEntityField('maxSpeed', DbType.real),
SqfEntityField('totalAscent', DbType.integer),
SqfEntityField('totalDescent', DbType.integer),
SqfEntityField('avgStanceTimePercent', DbType.real),
SqfEntityField('avgStanceTime', DbType.real),
SqfEntityField('maxRunningCadence', DbType.integer),
SqfEntityField('intensity', DbType.integer),
SqfEntityField('lapTrigger', DbType.text),
SqfEntityField('avgTemperature', DbType.integer),
SqfEntityField('maxTemperature', DbType.integer),
SqfEntityField('avgFractionalCadence', DbType.real),
SqfEntityField('maxFractionalCadence', DbType.real),
SqfEntityField('totalFractionalCycles', DbType.real),
SqfEntityFieldRelationship(
parentTable: tableEvent,
deleteRule: DeleteRule.CASCADE,
defaultValue: 0),
SqfEntityFieldRelationship(
parentTable: tableActivity,
deleteRule: DeleteRule.CASCADE,
defaultValue: 0),
]
);
@SqfEntityBuilder(encrateia)
const encrateia = SqfEntityModel(
modelName: 'DbEncrateia', // optional
......@@ -96,6 +149,7 @@ const encrateia = SqfEntityModel(
tableAthlete,
tableActivity,
tableEvent,
tableLap,
],
sequences: [],
bundledDatabasePath: null);
This diff is collapsed.
......@@ -4,8 +4,9 @@ import 'package:encrateia/model/model.dart';
import 'package:strava_flutter/strava.dart';
import 'package:encrateia/secrets/secrets.dart';
import 'package:strava_flutter/Models/activity.dart' as StravaActivity;
import 'package:encrateia/models/athlete.dart';
import 'package:encrateia/models/event.dart';
import 'athlete.dart';
import 'event.dart';
import 'lap.dart';
import 'package:fit_parser/fit_parser.dart';
import 'package:path_provider/path_provider.dart';
import 'package:encrateia/utils/date_time_utils.dart';
......@@ -108,7 +109,10 @@ class Activity extends ChangeNotifier {
break;
case "lap":
Event.fromLap(dataMessage: dataMessage, activity: this)
var event = Event.fromLap(dataMessage: dataMessage, activity: this);
print(dataMessage.values.map((v) => v.fieldName).toList());
debugger();
Lap(dataMessage: dataMessage, activity: this, eventId: 0);
break;
default:
......
......@@ -71,7 +71,20 @@ class Event {
Event.fromLap({DataMessage dataMessage, this.activity}) {
db = DbEvent()
..activitiesId = activity.db.id
// 40 values to add here ;-)
..positionLat = dataMessage.get('end_position_lat')
..positionLong = dataMessage.get('end_position_long')
..timeStamp = dateTimeFromStrava(dataMessage.get('timestamp'))
..event = dataMessage.get('event').toString()
..eventType = dataMessage.get('event_type')
..eventGroup = dataMessage.get('event_group').round()
..speed = dataMessage.get('avg_speed')
..verticalOscillation = dataMessage.get('avg_vertical_oscillation')
..fractionalCadence = dataMessage.get('avg_fractional_cadence')
..heartRate = dataMessage.get('avg_heart_rate').round()
..cadence = dataMessage.get('avg_running_cadence')
..timerTrigger = dataMessage.get('lap_trigger')
..distance = dataMessage.get('total_distance')
..save();
}
}
import 'package:encrateia/model/model.dart';
import 'package:fit_parser/fit_parser.dart';
import 'package:encrateia/utils/date_time_utils.dart';
import 'package:encrateia/utils/data_message_utils.dart';
import 'activity.dart';
class Lap {
DbLap db;
Activity activity;
Lap({DataMessage dataMessage, this.activity, int eventId})
{
db = DbLap()
..timeStamp = dateTimeFromStrava(dataMessage.get('timestamp'))
..startTime = dateTimeFromStrava(dataMessage.get('start_time'))
..startPositionLat = dataMessage.get('start_position_lat')
..startPositionLong = dataMessage.get('start_position_long')
..endPositionLong = dataMessage.get('end_position_lat')
..startPositionLat = dataMessage.get('end_position_long')
..save();
return;
}
}
// total_elapsed_time, total_timer_time, total_distance, total_strides,
// unknown, unknown, unknown, unknown, message_index, total_calories, avg_speed, max_speed, total_ascent, total_descent, wkt_step_index, avg_vertical_oscillation,
// avg_stance_time_percent, avg_stance_time, event, event_type, avg_heart_rate, max_heart_rate, avg_running_cadence, max_running_cadence, intensity, lap_trigger, sport,
// event_group, sub_sport, avg_temperature, max_temperature, unknown, avg_fractional_cadence, max_fractional_cadence, total_fractional_cycles
//SqfEntityField('avgHeartRate', DbType.integer),
//SqfEntityField('maxHeartRate', DbType.integer),
//SqfEntityField('avgRunningCadence', DbType.real),
//SqfEntityField('event', DbType.text),
//SqfEntityField('eventType', DbType.text),
//SqfEntityField('eventGroup', DbType.integer),
//SqfEntityField('sport', DbType.text),
//SqfEntityField('subSport', DbType.text),
//SqfEntityField('avgVerticalOscillation', DbType.real),
//SqfEntityField('totalElapsedTime', DbType.integer),
//SqfEntityField('totalTimerTime', DbType.integer),
//SqfEntityField('totalDistance', DbType.integer),
//SqfEntityField('totalStrides', DbType.integer),
//SqfEntityField('totalCalories', DbType.integer),
//SqfEntityField('avgSpeed', DbType.real),
//SqfEntityField('maxSpeed', DbType.real),
//SqfEntityField('totalAscent', DbType.integer),
//SqfEntityField('totalDescent', DbType.integer),
//SqfEntityField('avgStanceTimePercent', DbType.real),
//SqfEntityField('avgStanceTime', DbType.real),
//SqfEntityField('maxRunningCadence', DbType.integer),
//SqfEntityField('intensity', DbType.integer),
//SqfEntityField('lapTrigger', DbType.text),
//SqfEntityField('avgTemperature', DbType.integer),
//SqfEntityField('maxTemperature', DbType.integer),
//SqfEntityField('avgFractionalCadence', DbType.real),
//SqfEntityField('maxFractionalCadence', DbType.real),
//SqfEntityField('totalFractionalCycles', DbType.real),
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