Add Progress over time and a targets and reminders setup
Progress gives a Day/Week/Month view of routines held against a weekly target, compared with the same point of the previous period, with active time and the daily streak. Targets & reminders sets routines and minutes per week and schedules a heads-up before each routine. The runner's summary now shows today's held count and streak. Finished runs are mirrored to a device run log that feeds both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KhQh614DMeYoQEH9SoMRUw
This commit is contained in:
46
frontend/lib/Grounded/see/progress/ViewProgress.dart
Normal file
46
frontend/lib/Grounded/see/progress/ViewProgress.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
import '../../about/external/data/pages/request/HistoryRequest.dart';
|
||||
import '../../about/external/data/pages/request/PageAndSort.dart';
|
||||
import '../../about/external/data/pages/request/Pageable.dart';
|
||||
import '../../about/external/data/pages/request/Sort.dart';
|
||||
import '../../about/internal/application/ProgressTargets.dart';
|
||||
import '../../about/internal/application/RoutineRunRecord.dart';
|
||||
import '../../utils/ObjectConvertors.dart';
|
||||
import '../../utils/ProgressEngine.dart';
|
||||
import '../parent/ParentViewModel.dart';
|
||||
import 'ConnectProgress.dart';
|
||||
|
||||
class ViewProgress extends ParentViewModel {
|
||||
ConnectProgress connection;
|
||||
|
||||
ViewProgress(super.context, this.connection);
|
||||
|
||||
/// The runs and targets are on the device, so there is no network guard
|
||||
/// or spinner. Until a target is saved, the schedule stands in for it.
|
||||
void initialise() async {
|
||||
final List<RoutineRunRecord> records =
|
||||
await getDataManager().getRunLog();
|
||||
|
||||
final ProgressTargets targets =
|
||||
await getDataManager().getProgressTargets();
|
||||
|
||||
if (!targets.set) {
|
||||
try {
|
||||
final response = await getDataManager().getMyRoutines(HistoryRequest(
|
||||
query: PageAndSort(
|
||||
sort: Sort('asc', 'startMinute'),
|
||||
page: Pageable(0, 0, 50, 0),
|
||||
),
|
||||
));
|
||||
final int scheduled = ProgressEngine.scheduledPerWeek(
|
||||
getRoutineChainList(response.data));
|
||||
if (scheduled > 0) {
|
||||
targets.routinesPerWeek = scheduled;
|
||||
}
|
||||
} catch (e) {
|
||||
// Offline: the default target stands.
|
||||
}
|
||||
}
|
||||
|
||||
connection.onProgressLoaded(records, targets);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user