Skip to content

Commit 3248e90

Browse files
authored
Collect statistics about keys in pubspec.yaml files. (#1526)
* Collect statistics about keys in pubspec.yaml files. * k -> keyAsString
1 parent 7c7f1f2 commit 3248e90

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

app/bin/tools/pubspec_stats.dart

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
import 'package:appengine/appengine.dart';
8+
import 'package:gcloud/db.dart';
9+
10+
import 'package:pub_dartlang_org/frontend/models.dart';
11+
import 'package:pub_dartlang_org/frontend/service_utils.dart';
12+
13+
Future main(List<String> args) async {
14+
useLoggingPackageAdaptor();
15+
await withProdServices(() async {
16+
final counts = <String, int>{};
17+
18+
int index = 0;
19+
final query = dbService.query(PackageVersion);
20+
await for (PackageVersion pv in query.run().cast()) {
21+
index++;
22+
if (index % 100 == 0) {
23+
print('$index - ${pv.package} ${pv.version}');
24+
}
25+
pv.pubspec.asJson.keys.forEach((key) {
26+
final keyAsString = key.toString();
27+
counts[keyAsString] = (counts[keyAsString] ?? 0) + 1;
28+
});
29+
}
30+
31+
final sortedKeys = counts.keys.toList()..sort();
32+
for (String key in sortedKeys) {
33+
print('$key: ${counts[key]}');
34+
}
35+
});
36+
}

0 commit comments

Comments
 (0)