diff --git a/pub_stats/lib/controller/data_controller.dart b/pub_stats/lib/controller/data_controller.dart index afac418..fa6296a 100644 --- a/pub_stats/lib/controller/data_controller.dart +++ b/pub_stats/lib/controller/data_controller.dart @@ -1,6 +1,7 @@ import 'dart:math'; import 'package:fast_ui/fast_ui.dart'; +import 'package:firebase_database/firebase_database.dart'; import 'package:flutter/material.dart'; import 'package:get_it/get_it.dart'; import 'package:logger/logger.dart'; @@ -248,4 +249,9 @@ class DataController { _url.reset(); } + + Query diffQuery(String package) { + final query = _database.diffQuery(package); + return query; + } } diff --git a/pub_stats/lib/repo/database_repo.dart b/pub_stats/lib/repo/database_repo.dart index 8e107be..64456be 100644 --- a/pub_stats/lib/repo/database_repo.dart +++ b/pub_stats/lib/repo/database_repo.dart @@ -62,4 +62,8 @@ class DatabaseRepo { .child(uid) .set(configs.map((e) => e.toJson()).toList()); } + + Query diffQuery(String package) { + return _database.child('diffs').child(package).orderByKey(); + } } diff --git a/pub_stats/lib/view/widget/stats/stats_view.dart b/pub_stats/lib/view/widget/stats/stats_view.dart index a0fdb1d..7323665 100644 --- a/pub_stats/lib/view/widget/stats/stats_view.dart +++ b/pub_stats/lib/view/widget/stats/stats_view.dart @@ -1,10 +1,12 @@ import 'package:fast_ui/fast_ui.dart'; +import 'package:firebase_ui_database/firebase_ui_database.dart'; import 'package:flutter/material.dart'; import 'package:get_it/get_it.dart'; import 'package:pub_stats/controller/data_controller.dart'; import 'package:pub_stats/view/widget/global_stats_view.dart'; import 'package:pub_stats/view/widget/stats/developer_package_stats.dart'; import 'package:pub_stats/view/widget/stats/stats_charts.dart'; +import 'package:sliver_tools/sliver_tools.dart'; class StatsView extends StatelessWidget { final _controller = GetIt.I(); @@ -16,11 +18,28 @@ class StatsView extends StatelessWidget { return FastBuilder( () { if (_controller.loadedStats.isNotEmpty) { - return SliverToBoxAdapter( - child: StatsCharts( - stats: _controller.loadedStats, - onComparisonRemoved: _controller.removeStats, - ), + final singlePackage = _controller.loadedStats.length == 1 + ? _controller.loadedStats.first.package + : null; + return MultiSliver( + children: [ + SliverToBoxAdapter( + child: StatsCharts( + stats: _controller.loadedStats, + onComparisonRemoved: _controller.removeStats, + ), + ), + if (singlePackage != null) + FirebaseDatabaseListView( + query: _controller.diffQuery(singlePackage), + reverse: true, + itemBuilder: (context, snapshot) { + return const ListTile( + title: Text('asdf'), + ); + }, + ), + ], ); } else if (_controller.developerPackageStats.isNotEmpty) { return DeveloperPackageStats( diff --git a/pub_stats/pubspec.lock b/pub_stats/pubspec.lock index 2750edf..af42229 100644 --- a/pub_stats/pubspec.lock +++ b/pub_stats/pubspec.lock @@ -313,6 +313,22 @@ packages: url: "https://pub.dev" source: hosted version: "0.1.4+12" + firebase_ui_database: + dependency: "direct main" + description: + name: firebase_ui_database + sha256: "8f7834bbd6de9527f6461950f14998bbe49a3244999fe2effb8e1897ae6fe014" + url: "https://pub.dev" + source: hosted + version: "1.3.12" + firebase_ui_localizations: + dependency: transitive + description: + name: firebase_ui_localizations + sha256: "3f2548115b5f33fabc5cc47bee2f1d1d11a049381fbd64a8ecdd04fda6564319" + url: "https://pub.dev" + source: hosted + version: "1.8.0" fl_chart: dependency: "direct main" description: @@ -382,6 +398,11 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.1" + flutter_localizations: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" flutter_native_splash: dependency: "direct dev" description: @@ -661,6 +682,14 @@ packages: description: flutter source: sdk version: "0.0.99" + sliver_tools: + dependency: "direct main" + description: + name: sliver_tools + sha256: eae28220badfb9d0559207badcbbc9ad5331aac829a88cb0964d330d2a4636a6 + url: "https://pub.dev" + source: hosted + version: "0.2.12" source_span: dependency: transitive description: diff --git a/pub_stats/pubspec.yaml b/pub_stats/pubspec.yaml index 388d222..0dfc038 100644 --- a/pub_stats/pubspec.yaml +++ b/pub_stats/pubspec.yaml @@ -36,6 +36,8 @@ dependencies: collection: ^1.16.0 recase: ^4.1.0 + firebase_ui_database: ^1.3.12 + sliver_tools: ^0.2.12 dev_dependencies: flutter_test: diff --git a/pub_stats_collector/lib/controller/score_fetch_controller.dart b/pub_stats_collector/lib/controller/score_fetch_controller.dart index ec800fd..06feb87 100644 --- a/pub_stats_collector/lib/controller/score_fetch_controller.dart +++ b/pub_stats_collector/lib/controller/score_fetch_controller.dart @@ -84,8 +84,20 @@ class ScoreFetchController { await _database.writePackageData(package, data); - if (diff.isNotEmpty) { - await _database.writePackageDiff(package, diff); + + + // Don't track likes or popularity in diffs + final filteredDiff = Map.fromEntries( + diff.entries.where( + (e) => !{ + PackageDataField.likeCount, + PackageDataField.popularityScore, + }.contains(e.key), + ), + ); + + if (filteredDiff.isNotEmpty) { + await _database.writePackageDiff(package, filteredDiff); } }