Commit 17cd44bb authored by Administrator's avatar Administrator

autotagging admin job, autotag new activities

parent 41de5ac4
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_secure_storage","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.3/","dependencies":[]},{"name":"path_provider","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.8/","dependencies":[]},{"name":"shared_preferences","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+2/","dependencies":[]},{"name":"sqflite","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.0+1/","dependencies":[]},{"name":"uni_links","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/uni_links-0.4.0/","dependencies":[]},{"name":"url_launcher","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.4.7/","dependencies":[]}],"android":[{"name":"flutter_secure_storage","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.3/","dependencies":[]},{"name":"path_provider","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.8/","dependencies":[]},{"name":"shared_preferences","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+2/","dependencies":[]},{"name":"sqflite","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.0+1/","dependencies":[]},{"name":"uni_links","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/uni_links-0.4.0/","dependencies":[]},{"name":"url_launcher","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.4.7/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+2/","dependencies":[]},{"name":"shared_preferences_macos","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+8/","dependencies":[]},{"name":"sqflite","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.0+1/","dependencies":[]},{"name":"url_launcher_macos","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.0.1+5/","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"shared_preferences_web","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+5/","dependencies":[]},{"name":"url_launcher_web","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-0.1.1+5/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_secure_storage","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]},{"name":"uni_links","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_macos"]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2020-05-25 18:55:07.780940","version":"1.17.1"}
\ No newline at end of file
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_secure_storage","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.3/","dependencies":[]},{"name":"path_provider","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.8/","dependencies":[]},{"name":"shared_preferences","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+2/","dependencies":[]},{"name":"sqflite","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.0+1/","dependencies":[]},{"name":"uni_links","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/uni_links-0.4.0/","dependencies":[]},{"name":"url_launcher","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.4.7/","dependencies":[]}],"android":[{"name":"flutter_secure_storage","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.3/","dependencies":[]},{"name":"path_provider","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.8/","dependencies":[]},{"name":"shared_preferences","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+2/","dependencies":[]},{"name":"sqflite","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.0+1/","dependencies":[]},{"name":"uni_links","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/uni_links-0.4.0/","dependencies":[]},{"name":"url_launcher","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.4.7/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+2/","dependencies":[]},{"name":"shared_preferences_macos","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+8/","dependencies":[]},{"name":"sqflite","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.0+1/","dependencies":[]},{"name":"url_launcher_macos","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.0.1+5/","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"shared_preferences_web","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+5/","dependencies":[]},{"name":"url_launcher_web","path":"/home/stefan/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-0.1.1+5/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_secure_storage","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]},{"name":"uni_links","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_macos"]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2020-05-26 12:44:58.081997","version":"1.17.1"}
\ No newline at end of file
......@@ -18,7 +18,6 @@ import 'dart:developer';
import 'package:intl/intl.dart';
import 'package:encrateia/utils/enums.dart';
import 'dart:io';
import 'activity_tagging.dart';
import 'heart_rate_zone.dart';
import 'heart_rate_zone_schema.dart';
......@@ -556,7 +555,7 @@ class Activity extends ChangeNotifier {
return _heartRateZone;
}
autoTagger({Athlete athlete}) async {
autoTagger({@required Athlete athlete}) async {
PowerZone powerZone = await getPowerZone();
if (powerZone.db != null) {
Tag powerTag = await Tag.ensureAutoPowerTag(
......
......@@ -11,6 +11,7 @@ import 'package:encrateia/models/event.dart';
import 'package:encrateia/models/activity.dart';
import 'athlete.dart';
import 'heart_rate_zone_schema.dart';
import 'package:flutter/material.dart';
class Lap {
DbLap db;
......@@ -298,7 +299,7 @@ class Lap {
return _heartRateZone;
}
autoTagger({Athlete athlete}) async {
autoTagger({@required Athlete athlete}) async {
PowerZone powerZone = await getPowerZone();
if (powerZone.db != null) {
Tag powerTag = await Tag.ensureAutoPowerTag(
......
......@@ -62,7 +62,7 @@ class TagGroup extends ChangeNotifier {
await autoPowerZonesTagGroup.db.save();
}
static autoPowerTagGroup({Athlete athlete}) async {
static autoPowerTagGroup({@required Athlete athlete}) async {
var dbTagGroup = await DbTagGroup()
.select()
.system
......@@ -77,7 +77,7 @@ class TagGroup extends ChangeNotifier {
return TagGroup.fromDb(dbTagGroup);
}
static autoHeartRateTagGroup({Athlete athlete}) async {
static autoHeartRateTagGroup({@required Athlete athlete}) async {
var dbTagGroup = await DbTagGroup()
.select()
.system
......
......@@ -123,13 +123,6 @@ class _ShowAthleteScreenState extends State<ShowAthleteScreen> {
label: Text("Import .fit\nfrom Folder"),
onPressed: () => importLocal(),
),
RaisedButton.icon(
color: MyColor.add,
icon: MyIcon.settings,
textColor: MyColor.textColor(backgroundColor: MyColor.add),
label: Text("Recalculate\nAverages"),
onPressed: () => recalculate(),
),
navigationButton(
color: MyColor.settings,
title: "Body Weight",
......@@ -163,17 +156,24 @@ class _ShowAthleteScreenState extends State<ShowAthleteScreen> {
),
RaisedButton.icon(
color: MyColor.danger,
textColor: MyColor.white,
textColor: MyColor.textColor(backgroundColor: MyColor.danger),
icon: MyIcon.delete,
label: Text("Delete\nAthlete"),
onPressed: () => deleteUser(),
),
RaisedButton.icon(
color: MyColor.danger,
textColor: MyColor.white,
icon: MyIcon.delete,
label: Text("Delete all \n Autotags"),
onPressed: () => deleteAllAutoTags(),
color: MyColor.settings,
icon: MyIcon.settings,
textColor: MyColor.textColor(backgroundColor: MyColor.add),
label: Text("Recalculate\nAverages"),
onPressed: () => recalculate(),
),
RaisedButton.icon(
color: MyColor.settings,
textColor: MyColor.textColor(backgroundColor: MyColor.settings),
icon: MyIcon.settings,
label: Text("Redo \n Autotagging"),
onPressed: () => redoAutoTagging(),
),
RaisedButton.icon(
color: MyColor.primary,
......@@ -267,6 +267,7 @@ class _ShowAthleteScreenState extends State<ShowAthleteScreen> {
.toList();
for (Activity activity in downloadedActivities) {
await parse(activity: activity);
await activity.autoTagger(athlete: widget.athlete);
}
flushbar.dismiss();
flushbar = Flushbar(
......@@ -313,6 +314,7 @@ class _ShowAthleteScreenState extends State<ShowAthleteScreen> {
.toList();
for (Activity activity in downloadedActivities) {
await parse(activity: activity);
await activity.autoTagger(athlete: widget.athlete);
}
flushbar.dismiss();
flushbar = Flushbar(
......@@ -339,6 +341,7 @@ class _ShowAthleteScreenState extends State<ShowAthleteScreen> {
activities.where((activity) => activity.db.state == "downloaded");
for (Activity activity in downloadedActivities) {
await parse(activity: activity);
await activity.autoTagger(athlete: widget.athlete);
}
flushbar.dismiss();
......@@ -447,12 +450,44 @@ class _ShowAthleteScreenState extends State<ShowAthleteScreen> {
Navigator.of(context).popUntil((route) => route.isFirst);
}
deleteAllAutoTags() async {
redoAutoTagging() async {
flushbar = Flushbar(
message: "Started cleaning up...",
duration: Duration(seconds: 5),
icon: MyIcon.finishedWhite,
)..show(context);
List<Activity> activities;
activities = await Activity.all(athlete: widget.athlete);
int index = 0;
int percent;
await TagGroup.deleteAllAutoTags(athlete: widget.athlete);
Flushbar(
message: "All Autotags have been deleted.",
message: "All existing autotaggings have been deleted.",
duration: Duration(seconds: 2),
icon: MyIcon.finishedWhite,
)..show(context);
for (Activity activity in activities) {
index += 1;
await activity.autoTagger(athlete: widget.athlete);
flushbar.dismiss();
percent = 100 * index ~/ activities.length;
flushbar = Flushbar(
titleText: LinearProgressIndicator(value: percent / 100),
message: "$percent% done (autotagging »${activity.db.name}« )",
duration: Duration(seconds: 2),
animationDuration: Duration(milliseconds: 1),
)..show(context);
}
flushbar.dismiss();
Flushbar(
message: "Autotaggings are now up to date.",
duration: Duration(seconds: 5),
icon: MyIcon.finishedWhite,
)..show(context);
}
}
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