forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_usage.dart
More file actions
125 lines (107 loc) · 4.02 KB
/
Copy pathuser_usage.dart
File metadata and controls
125 lines (107 loc) · 4.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import 'package:omi/backend/schema/gen/subscription_usage_wire.g.dart' as wire;
class UsageStats {
final int transcriptionSeconds;
final int speechSeconds;
final int wordsTranscribed;
final int insightsGained;
final int memoriesCreated;
UsageStats({
required this.transcriptionSeconds,
required this.speechSeconds,
required this.wordsTranscribed,
required this.insightsGained,
required this.memoriesCreated,
});
factory UsageStats.fromJson(Map<String, dynamic> json) {
return UsageStats.fromGenerated(wire.GeneratedUsageStats.fromJson(json));
}
factory UsageStats.fromGenerated(wire.GeneratedUsageStats generated) {
return UsageStats(
transcriptionSeconds: generated.transcriptionSeconds,
speechSeconds: generated.speechSeconds,
wordsTranscribed: generated.wordsTranscribed,
insightsGained: generated.insightsGained,
memoriesCreated: generated.memoriesCreated,
);
}
wire.GeneratedUsageStats toGenerated() {
return wire.GeneratedUsageStats(
transcriptionSeconds: transcriptionSeconds,
speechSeconds: speechSeconds,
wordsTranscribed: wordsTranscribed,
insightsGained: insightsGained,
memoriesCreated: memoriesCreated,
);
}
Map<String, dynamic> toJson() => toGenerated().toJson();
}
class UsageHistoryPoint {
final String date;
final int transcriptionSeconds;
final int speechSeconds;
final int wordsTranscribed;
final int insightsGained;
final int memoriesCreated;
UsageHistoryPoint({
required this.date,
required this.transcriptionSeconds,
required this.speechSeconds,
required this.wordsTranscribed,
required this.insightsGained,
required this.memoriesCreated,
});
factory UsageHistoryPoint.fromJson(Map<String, dynamic> json) {
return UsageHistoryPoint.fromGenerated(wire.GeneratedUsageHistoryPoint.fromJson(json));
}
factory UsageHistoryPoint.fromGenerated(wire.GeneratedUsageHistoryPoint generated) {
return UsageHistoryPoint(
date: generated.date,
transcriptionSeconds: generated.transcriptionSeconds,
speechSeconds: generated.speechSeconds,
wordsTranscribed: generated.wordsTranscribed,
insightsGained: generated.insightsGained,
memoriesCreated: generated.memoriesCreated,
);
}
wire.GeneratedUsageHistoryPoint toGenerated() {
return wire.GeneratedUsageHistoryPoint(
date: date,
transcriptionSeconds: transcriptionSeconds,
speechSeconds: speechSeconds,
wordsTranscribed: wordsTranscribed,
insightsGained: insightsGained,
memoriesCreated: memoriesCreated,
);
}
Map<String, dynamic> toJson() => toGenerated().toJson();
}
class UserUsageResponse {
final UsageStats? today;
final UsageStats? monthly;
final UsageStats? yearly;
final UsageStats? allTime;
final List<UsageHistoryPoint>? history;
UserUsageResponse({this.today, this.monthly, this.yearly, this.allTime, this.history});
factory UserUsageResponse.fromJson(Map<String, dynamic> json) {
return UserUsageResponse.fromGenerated(wire.GeneratedUserUsageResponse.fromJson(json));
}
factory UserUsageResponse.fromGenerated(wire.GeneratedUserUsageResponse generated) {
return UserUsageResponse(
today: generated.today == null ? null : UsageStats.fromGenerated(generated.today!),
monthly: generated.monthly == null ? null : UsageStats.fromGenerated(generated.monthly!),
yearly: generated.yearly == null ? null : UsageStats.fromGenerated(generated.yearly!),
allTime: generated.allTime == null ? null : UsageStats.fromGenerated(generated.allTime!),
history: generated.history?.map(UsageHistoryPoint.fromGenerated).toList(),
);
}
wire.GeneratedUserUsageResponse toGenerated() {
return wire.GeneratedUserUsageResponse(
today: today?.toGenerated(),
monthly: monthly?.toGenerated(),
yearly: yearly?.toGenerated(),
allTime: allTime?.toGenerated(),
history: history?.map((point) => point.toGenerated()).toList(),
);
}
Map<String, dynamic> toJson() => toGenerated().toJson();
}