Skip to content

Commit

Permalink
Fixing analysis issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexios80 committed Nov 13, 2024
1 parent 4a0038a commit a05c9ea
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 18 deletions.
4 changes: 2 additions & 2 deletions pub_stats/lib/model/time_span.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ enum TimeSpan {

bool contains(DateTime date) {
if (days == null) return true;
final diff = DateTime.now().difference(date);
final diff = DateTime.timestamp().difference(date);
return diff.inDays <= days!;
}

Expand All @@ -26,7 +26,7 @@ enum TimeSpan {
return DateTime.fromMillisecondsSinceEpoch(0);
}

final now = DateTime.now();
final now = DateTime.timestamp();
return DateTime(now.year, now.month, now.day)
.subtract(Duration(days: days));
}
Expand Down
7 changes: 5 additions & 2 deletions pub_stats/lib/view/screen/alerts_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class AlertsManager extends StatelessWidget {
Expanded(
child: SearchAnchor.bar(
viewConstraints: const BoxConstraints(),
viewBarPadding: const EdgeInsets.symmetric(horizontal: 16),
viewBarPadding:
const EdgeInsets.symmetric(horizontal: 16),
shrinkWrap: true,
barLeading: const SizedBox.shrink(),
viewLeading: const SizedBox.shrink(),
Expand Down Expand Up @@ -191,7 +192,9 @@ class AlertsManager extends StatelessWidget {
ignore: ignoredFields,
type: selectedType.value,
extra: extraController.text,
)) return;
)) {
return;
}

slugController.clear();
extraController.clear();
Expand Down
3 changes: 2 additions & 1 deletion pub_stats_collector/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ targets:
source_gen|combining_builder:
options:
ignore_for_file:
- require_trailing_commas
- document_ignores
- require_trailing_commas
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ class ScoreFetchController {
) : _pub = PubRepo(credentials);

Future<void> fetchScores() async {
final startTime = DateTime.now();
final startTime = DateTime.timestamp();
final globalStats = await _pub.fetchAllData(_handleData);

await _database.writeGlobalStats(globalStats);
print('Global stats:');
print(globalStats.toJson());

final duration = DateTime.now().difference(startTime);
final duration = DateTime.timestamp().difference(startTime);
print('Package processing completed in ${duration.inSeconds} seconds');

for (final config in _alertConfigs['.system'] ?? <AlertConfig>[]) {
Expand Down
6 changes: 4 additions & 2 deletions pub_stats_collector/lib/credential/credentials.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:convert';
import 'dart:io';
import 'package:path/path.dart' as path;

class Credentials {
static const _userAgent = 'Rexios80/pub_stats_collector';
Expand All @@ -12,8 +13,9 @@ class Credentials {

static final debug = Credentials._(
userAgent: _userAgent,
serviceAccount:
jsonDecode(File('secret/service_account_key.json').readAsStringSync()),
serviceAccount: jsonDecode(
File(path.join('secret', 'service_account_key.json')).readAsStringSync(),
),
databaseUrl: 'http://127.0.0.1:9000/?ns=pub-stats-collector-default-rtdb',
);

Expand Down
4 changes: 2 additions & 2 deletions pub_stats_collector/lib/repo/database_repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class DatabaseRepo {
.ref()
.child('diffs')
.child(package)
.child(DateTime.now().secondsSinceEpoch.toString())
.child(DateTime.timestamp().secondsSinceEpoch.toString())
.set(diff.toJson());
}

Expand All @@ -47,7 +47,7 @@ class DatabaseRepo {
await _database
.ref()
.child('package_counts')
.child(DateTime.now().secondsSinceEpoch.toString())
.child(DateTime.timestamp().secondsSinceEpoch.toString())
.set(stats.packageCount);
}

Expand Down
2 changes: 1 addition & 1 deletion pub_stats_collector/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ packages:
source: hosted
version: "2.1.0"
path:
dependency: transitive
dependency: "direct main"
description:
name: path
sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
Expand Down
1 change: 1 addition & 0 deletions pub_stats_collector/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies:
discord_interactions: ^0.0.15
flutter_tools_task_queue: ^1.0.0
recase: ^4.1.0
path: ^1.9.1

dev_dependencies:
rexios_lints: ^8.2.0
Expand Down
9 changes: 8 additions & 1 deletion pub_stats_collector/tool/prune.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@ import 'dart:convert';
import 'dart:io';

import 'package:pub_stats_core/pub_stats_core.dart';
import 'package:path/path.dart' as path;

/// Prune duplicate score entries from the database
void main() {
final string = File(
'/Users/rexios/Downloads/pub-stats-collector-default-rtdb-export.json',
path.join(
'',
'Users',
'rexios',
'Downloads',
'pub-stats-collector-default-rtdb-export.json',
),
).readAsStringSync();
final json = jsonDecode(string) as Map<String, dynamic>;
final packages = json['stats'] as Map<String, dynamic>;
Expand Down
1 change: 1 addition & 0 deletions pub_stats_core/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ targets:
source_gen|combining_builder:
options:
ignore_for_file:
- document_ignores
- require_trailing_commas
2 changes: 1 addition & 1 deletion pub_stats_core/lib/src/model/alert_config.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pub_stats_core/lib/src/model/diff.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pub_stats_core/lib/src/model/global_stats.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pub_stats_core/lib/src/model/mini_package_score.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pub_stats_core/lib/src/model/package_data.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// These are valid
// ignore_for_file: invalid_annotation_target

import 'package:freezed_annotation/freezed_annotation.dart';
Expand Down
2 changes: 1 addition & 1 deletion pub_stats_core/lib/src/model/package_data.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a05c9ea

Please sign in to comment.