a7c3795e5a
device_usage.dart 一直是 untracked(stats-overhaul WIP 漏提交),本地有所以 analyze/test 过,但不在 git → bundle → Windows 构建报「找不到 device_usage.dart / DeviceUsage isn't a type」。account_providers/account_api/golden 测试都引用它,补提交。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
34 lines
1.0 KiB
Dart
34 lines
1.0 KiB
Dart
// device_usage.dart — 单设备窗口用量(GET /v1/usage/devices?days=N 的一条)。
|
|
// 统计页「下分设备」明细的数据载体,与账户聚合的 UsagePoint 对应。
|
|
class DeviceUsage {
|
|
const DeviceUsage({
|
|
required this.uuid,
|
|
required this.name,
|
|
required this.platform,
|
|
this.bytesUp = 0,
|
|
this.bytesDown = 0,
|
|
this.minutesUsed = 0,
|
|
});
|
|
|
|
final String uuid;
|
|
final String name;
|
|
|
|
/// ios | android | windows | macos。
|
|
final String platform;
|
|
final int bytesUp;
|
|
final int bytesDown;
|
|
final int minutesUsed;
|
|
|
|
int get bytesTotal => bytesUp + bytesDown;
|
|
double get gbTotal => bytesTotal / (1024 * 1024 * 1024);
|
|
|
|
factory DeviceUsage.fromJson(Map<String, dynamic> m) => DeviceUsage(
|
|
uuid: m['uuid'] as String? ?? '',
|
|
name: m['name'] as String? ?? '',
|
|
platform: m['platform'] as String? ?? '',
|
|
bytesUp: (m['bytes_up'] as num?)?.toInt() ?? 0,
|
|
bytesDown: (m['bytes_down'] as num?)?.toInt() ?? 0,
|
|
minutesUsed: (m['minutes_used'] as num?)?.toInt() ?? 0,
|
|
);
|
|
}
|