From 50cfd48e5107223c67e7b3af9194fd8f4ae2100b Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Sat, 7 Dec 2019 16:22:05 +0800 Subject: [PATCH] fix: commit history count --- lib/graphql/github_repository.dart | 12 ++++++++++++ lib/graphql/github_repository.graphql | 2 ++ lib/screens/repository.dart | 9 +++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/graphql/github_repository.dart b/lib/graphql/github_repository.dart index 1130e4a..c232e8c 100644 --- a/lib/graphql/github_repository.dart +++ b/lib/graphql/github_repository.dart @@ -1055,6 +1055,12 @@ class GithubRepositoryQuery arguments: [], directives: [], selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null), InlineFragmentNode( typeCondition: TypeConditionNode( on: NamedTypeNode( @@ -1110,6 +1116,12 @@ class GithubRepositoryQuery arguments: [], directives: [], selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null), InlineFragmentNode( typeCondition: TypeConditionNode( on: NamedTypeNode( diff --git a/lib/graphql/github_repository.graphql b/lib/graphql/github_repository.graphql index 4ffd365..0226593 100644 --- a/lib/graphql/github_repository.graphql +++ b/lib/graphql/github_repository.graphql @@ -59,6 +59,7 @@ query( defaultBranchRef @skip(if: $branchSpecified) { name target { + __typename ... on Commit { history { totalCount @@ -69,6 +70,7 @@ query( ref(qualifiedName: $branch) @include(if: $branchSpecified) { name target { + __typename ... on Commit { history { totalCount diff --git a/lib/screens/repository.dart b/lib/screens/repository.dart index 8022399..b3dbdd3 100644 --- a/lib/screens/repository.dart +++ b/lib/screens/repository.dart @@ -230,8 +230,13 @@ class RepositoryScreen extends StatelessWidget { TableViewItem( leftIconData: Octicons.history, text: Text('Commits'), - // rightWidget: Text(numberFormat - // .format(ref['target']['history']['totalCount'])), + rightWidget: Text( + numberFormat.format( + (ref.target as GithubRepositoryCommit) + .history + ?.totalCount, + ), + ), screenBuilder: (_) => CommitsScreen(owner, name, branch: branch), ),