Skip to content

Commit

Permalink
Don't track likes and popularity in diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexios80 committed Nov 21, 2023
1 parent d0ed69e commit 0861865
Showing 6 changed files with 79 additions and 7 deletions.
6 changes: 6 additions & 0 deletions pub_stats/lib/controller/data_controller.dart
Original file line number Diff line number Diff line change
@@ -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;
}
}
4 changes: 4 additions & 0 deletions pub_stats/lib/repo/database_repo.dart
Original file line number Diff line number Diff line change
@@ -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();
}
}
29 changes: 24 additions & 5 deletions pub_stats/lib/view/widget/stats/stats_view.dart
Original file line number Diff line number Diff line change
@@ -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<DataController>();
@@ -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(
29 changes: 29 additions & 0 deletions pub_stats/pubspec.lock
Original file line number Diff line number Diff line change
@@ -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:
2 changes: 2 additions & 0 deletions pub_stats/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
16 changes: 14 additions & 2 deletions pub_stats_collector/lib/controller/score_fetch_controller.dart
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 0861865

Please sign in to comment.