add PR stats to the 'bin/report.dart weekly' command (#198)
diff --git a/pkgs/repo_manage/lib/issue_transfer.dart b/pkgs/repo_manage/lib/issue_transfer.dart
index 2d0bef8..d69cc3d 100644
--- a/pkgs/repo_manage/lib/issue_transfer.dart
+++ b/pkgs/repo_manage/lib/issue_transfer.dart
@@ -39,7 +39,7 @@
argParser.addOption(
'add-label',
help: 'Add a label to all transferred issues.',
- valueHelp: 'pkg:foo',
+ valueHelp: 'package:foo',
);
}
diff --git a/pkgs/repo_manage/lib/src/common.dart b/pkgs/repo_manage/lib/src/common.dart
index fa9eecb..4f4e7dd 100644
--- a/pkgs/repo_manage/lib/src/common.dart
+++ b/pkgs/repo_manage/lib/src/common.dart
@@ -126,6 +126,7 @@
final String repo;
final int issuesOpened;
final int issuesClosed;
+ final int prsOpened;
final int commits;
final int p0Count;
final int p1Count;
@@ -135,6 +136,7 @@
this.repo, {
required this.issuesOpened,
required this.issuesClosed,
+ required this.prsOpened,
required this.commits,
required this.p0Count,
required this.p1Count,
diff --git a/pkgs/repo_manage/lib/weekly.dart b/pkgs/repo_manage/lib/weekly.dart
index cc98024..a3d47e9 100644
--- a/pkgs/repo_manage/lib/weekly.dart
+++ b/pkgs/repo_manage/lib/weekly.dart
@@ -21,7 +21,7 @@
..addFlag(
'dart-lang',
negatable: false,
- help: 'Return stats for add dart-lang repos.',
+ help: 'Return stats for all dart-lang repos.',
)
..addFlag(
'monthly',
@@ -89,6 +89,11 @@
from: firstReportingDay,
to: lastReportingDay,
),
+ prsOpened: await queryPRsOpened(
+ repo: repo,
+ from: firstReportingDay,
+ to: lastReportingDay,
+ ),
commits: await queryCommitsSince(
repo: repo,
since: firstReportingDay,
@@ -101,13 +106,14 @@
}));
print('');
- print('Repo,Issues Opened,Issues Closed,Commits,P0s,P1s,Stars');
+ print('Repo,Issues Opened,Issues Closed,PRs Opened,Commits,P0s,P1s,Stars');
for (var info in infos) {
print(
'${info.repo},'
'${info.issuesOpened},'
'${info.issuesClosed},'
+ '${info.prsOpened},'
'${info.commits},'
'${info.p0Count},'
'${info.p1Count},'
@@ -119,8 +125,10 @@
print(
'All: '
- '${infos.fold(0, (count, info) => count + info.issuesOpened)} opened, '
+ '${infos.fold(0, (count, info) => count + info.issuesOpened)} issues '
+ 'opened, '
'${infos.fold(0, (count, info) => count + info.issuesClosed)} closed, '
+ '${infos.fold(0, (count, info) => count + info.prsOpened)} PRs, '
'${infos.fold(0, (count, info) => count + info.commits)} commits, '
'${infos.fold(0, (count, info) => count + info.p0Count)} P0s, '
'${infos.fold(0, (count, info) => count + info.p1Count)} P1s, '
@@ -178,6 +186,30 @@
return result.hasException ? throw result.exception! : result.parsedData!;
}
+ Future<int> queryPRsOpened({
+ required RepositorySlug repo,
+ required DateTime from,
+ required DateTime to,
+ }) async {
+ final queryString = '''{
+ search(query: "repo:${repo.fullName} is:pr created:${iso8601String(from)}..${iso8601String(to)}", type: ISSUE, last: 100) {
+ issueCount
+ edges {
+ node {
+ ... on PullRequest { title url createdAt number state }
+ }
+ }
+ }
+}''';
+
+ final result = await query(QueryOptions(
+ document: gql(queryString),
+ parserFn: (data) => (data['search'] as Map)['issueCount']! as int,
+ ));
+
+ return result.hasException ? throw result.exception! : result.parsedData!;
+ }
+
Future<int> queryCommitsSince({
required RepositorySlug repo,
required DateTime since,