-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
73 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'service/stats.dart'; | ||
import 'storage/stats.dart'; | ||
|
||
class StatsInit { | ||
static late final StatsStorage storage; | ||
static late final StatsService service; | ||
|
||
static void init() { | ||
service = StatsService(); | ||
} | ||
|
||
static void initStorage() { | ||
storage = StatsStorage(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
class StatsService {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import 'package:objectbox/objectbox.dart'; | ||
import 'package:mimir/storage/objectbox/init.dart'; | ||
|
||
import '../entity/feature.dart'; | ||
import '../entity/route.dart'; | ||
|
||
class StatsStorage { | ||
late final Box<StatsFeatureUsage> feature = ObjectBoxInit.store.box<StatsFeatureUsage>(); | ||
late final Box<StatsRoute> route = ObjectBoxInit.store.box<StatsRoute>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:mimir/backend/stats/entity/route.dart'; | ||
|
||
import '../entity/feature.dart'; | ||
import '../init.dart'; | ||
|
||
class Stats { | ||
static String? lastRoute; | ||
|
||
static void onRoute(Uri uri) { | ||
final route = uri.toString(); | ||
if (route == lastRoute) { | ||
return; | ||
} | ||
lastRoute = route; | ||
final time = DateTime.now(); | ||
final row = StatsRoute( | ||
route: route.toString(), | ||
time: time, | ||
); | ||
final id = StatsInit.storage.route.put(row); | ||
debugPrint('[${time.toString()}] On route #$id: "$route"'); | ||
} | ||
|
||
static void onFeature(String feature, [String? result]) { | ||
final time = DateTime.now(); | ||
final row = StatsFeatureUsage( | ||
feature: feature, | ||
result: result ?? "", | ||
time: time, | ||
); | ||
final id = StatsInit.storage.feature.put(row); | ||
debugPrint('[${time.toString()}] On feature #$id: "$feature"'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters