Commit 381dbae8 authored by Markus Koller's avatar Markus Koller

Merge branch 'ajk-gql-diff-stats-file-count' into 'master'

Add MergeRequest.diffStatSummary.fileCount to graphql API

See merge request gitlab-org/gitlab!35685
parents 34cbb7cd d23a7197
......@@ -14,6 +14,8 @@ module Types
description: 'Number of lines deleted'
field :changes, GraphQL::INT_TYPE, null: false,
description: 'Number of lines changed'
field :file_count, GraphQL::INT_TYPE, null: false,
description: 'Number of files changed'
def changes
object[:additions] + object[:deletions]
......
......@@ -153,11 +153,11 @@ module Types
end
def diff_stats_summary
nil_stats = { additions: 0, deletions: 0 }
nil_stats = { additions: 0, deletions: 0, file_count: 0 }
return nil_stats unless object.diff_stats.present?
object.diff_stats.each_with_object(nil_stats) do |status, hash|
hash.merge!(additions: status.additions, deletions: status.deletions) { |_, x, y| x + y }
hash.merge!(additions: status.additions, deletions: status.deletions, file_count: 1) { |_, x, y| x + y }
end
end
end
......
---
title: Add MergeRequest.diffStatsSummary.fileCount to graphql API
merge_request: 35685
author:
type: added
......@@ -3164,6 +3164,11 @@ type DiffStatsSummary {
Number of lines deleted
"""
deletions: Int!
"""
Number of files changed
"""
fileCount: Int!
}
type Discussion implements ResolvableInterface {
......
......@@ -8778,6 +8778,24 @@
"description": "Number of lines deleted",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "fileCount",
"description": "Number of files changed",
"args": [
],
"type": {
"kind": "NON_NULL",
......@@ -545,6 +545,7 @@ Aggregated summary of changes
| `additions` | Int! | Number of lines added |
| `changes` | Int! | Number of lines changed |
| `deletions` | Int! | Number of lines deleted |
| `fileCount` | Int! | Number of files changed |
## Discussion
......
......@@ -55,7 +55,12 @@ RSpec.describe 'getting merge request information nested in a project' do
expect(merge_request_graphql_data).to include(
'diffStats' => all(a_hash_including('path' => String, 'additions' => be_natural, 'deletions' => be_natural)),
'diffStatsSummary' => a_hash_including('additions' => be_natural, 'deletions' => be_natural, 'changes' => be_natural)
'diffStatsSummary' => a_hash_including(
'fileCount' => merge_request.diff_stats.count,
'additions' => be_natural,
'deletions' => be_natural,
'changes' => be_natural
)
)
# diff_stats is consistent with summary
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment