|
|
|
import 'package:doublefeel_flutter/core/network/api/health_api.dart';
|
|
|
|
import 'package:doublefeel_flutter/core/result/app_result.dart';
|
|
|
|
import 'package:doublefeel_flutter/data/datasource/health/health_datasource.dart';
|
|
|
|
import 'package:doublefeel_flutter/data/models/health/activity/activity_burn_statistics_data_v2.dart';
|
|
|
|
|
|
|
|
import '../models/activity_burn_report_models.dart';
|
|
...
|
...
|
@@ -22,13 +22,13 @@ abstract class ActivityBurnReportDataSource { |
|
|
|
}
|
|
|
|
|
|
|
|
class ApiActivityBurnReportDataSource implements ActivityBurnReportDataSource {
|
|
|
|
const ApiActivityBurnReportDataSource(this._healthApi);
|
|
|
|
const ApiActivityBurnReportDataSource(this._healthDataSource);
|
|
|
|
|
|
|
|
static const _weekDateRangeType = 0;
|
|
|
|
static const _monthDateRangeType = 1;
|
|
|
|
static const _dayDateRangeType = 3;
|
|
|
|
|
|
|
|
final HealthApi _healthApi;
|
|
|
|
final HealthDataSource _healthDataSource;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Future<ActivityBurnReport> fetchDailyReport(
|
|
...
|
...
|
@@ -36,7 +36,7 @@ class ApiActivityBurnReportDataSource implements ActivityBurnReportDataSource { |
|
|
|
int? targetUserId,
|
|
|
|
}) async {
|
|
|
|
final day = _normalizeDate(date);
|
|
|
|
final result = await _healthApi.getActivityBurnStatistics(
|
|
|
|
final result = await _healthDataSource.getActivityBurnStatistics(
|
|
|
|
_dayDateRangeType,
|
|
|
|
_dateKey(day),
|
|
|
|
queryUserId: targetUserId,
|
|
...
|
...
|
@@ -53,7 +53,7 @@ class ApiActivityBurnReportDataSource implements ActivityBurnReportDataSource { |
|
|
|
int? targetUserId,
|
|
|
|
}) async {
|
|
|
|
final start = _normalizeDate(weekStart);
|
|
|
|
final result = await _healthApi.getActivityBurnStatistics(
|
|
|
|
final result = await _healthDataSource.getActivityBurnStatistics(
|
|
|
|
_weekDateRangeType,
|
|
|
|
_dateKey(start),
|
|
|
|
queryUserId: targetUserId,
|
|
...
|
...
|
@@ -81,7 +81,7 @@ class ApiActivityBurnReportDataSource implements ActivityBurnReportDataSource { |
|
|
|
}) async {
|
|
|
|
final start = DateTime(monthStart.year, monthStart.month);
|
|
|
|
final end = DateTime(start.year, start.month + 1, 0);
|
|
|
|
final result = await _healthApi.getActivityBurnStatistics(
|
|
|
|
final result = await _healthDataSource.getActivityBurnStatistics(
|
|
|
|
_monthDateRangeType,
|
|
|
|
_dateKey(start),
|
|
|
|
queryUserId: targetUserId,
|
|
...
|
...
|
@@ -317,4 +317,4 @@ class _SleepRange { |
|
|
|
|
|
|
|
final DateTime start;
|
|
|
|
final DateTime end;
|
|
|
|
} |
|
|
\ No newline at end of file |
|
|
|
} |
...
|
...
|
|