Skip to content

Commit c60cfbe

Browse files
committed
Add tables for workout sessions
1 parent 14ff95a commit c60cfbe

31 files changed

+4975
-2674
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* This file is part of wger Workout Manager <https://github.com/wger-project>.
3+
* Copyright (c) 2020, 2020- wger Team
4+
*
5+
* wger Workout Manager is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
import 'package:drift/drift.dart';
20+
21+
class IntToStringConverter extends TypeConverter<int, String> {
22+
const IntToStringConverter();
23+
24+
@override
25+
int fromSql(String fromDb) {
26+
return int.parse(fromDb);
27+
}
28+
29+
@override
30+
String toSql(int value) {
31+
return value.toString();
32+
}
33+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* This file is part of wger Workout Manager <https://github.com/wger-project>.
3+
* Copyright (c) 2020, 2020- wger Team
4+
*
5+
* wger Workout Manager is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
import 'package:drift/drift.dart';
20+
import 'package:flutter/material.dart';
21+
import 'package:wger/helpers/json.dart';
22+
23+
class TimeOfDayConverter extends TypeConverter<TimeOfDay, String> {
24+
const TimeOfDayConverter();
25+
26+
@override
27+
TimeOfDay fromSql(String fromDb) {
28+
return stringToTimeNull(fromDb)!;
29+
}
30+
31+
@override
32+
String toSql(TimeOfDay value) {
33+
return timeToString(value)!;
34+
}
35+
}

lib/database/powersync/database.dart

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
1+
/*
2+
* This file is part of wger Workout Manager <https://github.com/wger-project>.
3+
* Copyright (c) 2020, wger Team
4+
*
5+
* wger Workout Manager is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
119
import 'package:drift/drift.dart';
220
import 'package:drift_sqlite_async/drift_sqlite_async.dart';
21+
import 'package:flutter/material.dart' show TimeOfDay;
322
import 'package:flutter_riverpod/flutter_riverpod.dart';
423
import 'package:powersync/powersync.dart' show uuid;
24+
import 'package:wger/database/converters/int_to_string_converter.dart';
25+
import 'package:wger/database/converters/time_of_day_converter.dart';
526
import 'package:wger/models/body_weight/weight_entry.dart';
627
import 'package:wger/models/exercises/category.dart';
728
import 'package:wger/models/exercises/equipment.dart';
@@ -12,11 +33,14 @@ import 'package:wger/models/exercises/muscle.dart';
1233
import 'package:wger/models/exercises/translation.dart';
1334
import 'package:wger/models/exercises/video.dart';
1435
import 'package:wger/models/measurements/measurement_category.dart';
36+
import 'package:wger/models/workouts/log.dart';
37+
import 'package:wger/models/workouts/session.dart';
1538

1639
import 'powersync.dart';
1740
import 'tables/exercise.dart';
1841
import 'tables/language.dart';
1942
import 'tables/measurements.dart';
43+
import 'tables/routines.dart';
2044
import 'tables/weight.dart';
2145

2246
part 'database.g.dart';
@@ -41,7 +65,8 @@ part 'database.g.dart';
4165
// User data
4266
WeightEntryTable,
4367
MeasurementCategoryTable,
44-
// WorkoutLogTable,
68+
WorkoutLogTable,
69+
WorkoutSessionTable,
4570
],
4671
//include: {'queries.drift'},
4772
)

0 commit comments

Comments
 (0)