Class: Types::MergeRequestType
- Inherits:
-
BaseObject
- Object
- GraphQL::Schema::Object
- BaseObject
- Types::MergeRequestType
show all
- Defined in:
- app/graphql/types/merge_request_type.rb
Instance Method Summary
collapse
Methods inherited from BaseObject
accepts, assignable?, authorization, authorize, authorized?, #current_user, #id
#present, #unpresented
Instance Method Details
#available_auto_merge_strategies ⇒ Object
297
298
299
|
# File 'app/graphql/types/merge_request_type.rb', line 297
def available_auto_merge_strategies
AutoMergeService.new(object.project, current_user).available_strategies(object)
end
|
#commits ⇒ Object
301
302
303
|
# File 'app/graphql/types/merge_request_type.rb', line 301
def commits
object.commits.commits
end
|
#commits_without_merge_commits ⇒ Object
305
306
307
|
# File 'app/graphql/types/merge_request_type.rb', line 305
def commits_without_merge_commits
object.commits.without_merge_commits
end
|
#committers ⇒ Object
This is temporary to fix a bug where ‘committers` is already loaded and memoized and calling it again with a certain GraphQL query can cause the Rails to to throw a ActiveRecord::ImmutableRelation error
324
325
326
|
# File 'app/graphql/types/merge_request_type.rb', line 324
def committers
object.commits.committers
end
|
#default_merge_commit_message ⇒ Object
289
290
291
|
# File 'app/graphql/types/merge_request_type.rb', line 289
def default_merge_commit_message
object.default_merge_commit_message(include_description: false, user: current_user)
end
|
#default_squash_commit_message ⇒ Object
293
294
295
|
# File 'app/graphql/types/merge_request_type.rb', line 293
def default_squash_commit_message
object.default_squash_commit_message(user: current_user)
end
|
#detailed_merge_status ⇒ Object
#diff_stats(path: nil) ⇒ Object
267
268
269
270
271
272
273
274
275
|
# File 'app/graphql/types/merge_request_type.rb', line 267
def diff_stats(path: nil)
stats = Array.wrap(object.diff_stats&.to_a)
if path.present?
stats.select { |s| s.path == path }
else
stats
end
end
|
#diff_stats_summary ⇒ Object
#discussion_locked ⇒ Object
285
286
287
|
# File 'app/graphql/types/merge_request_type.rb', line 285
def discussion_locked
!!object.discussion_locked
end
|
#merge_user ⇒ Object
313
314
315
|
# File 'app/graphql/types/merge_request_type.rb', line 313
def merge_user
object.metrics&.merged_by || object.merge_user
end
|
#security_auto_fix ⇒ Object
309
310
311
|
# File 'app/graphql/types/merge_request_type.rb', line 309
def security_auto_fix
object.author == ::Users::Internal.security_bot
end
|
#source_branch_protected ⇒ Object
281
282
283
|
# File 'app/graphql/types/merge_request_type.rb', line 281
def source_branch_protected
object.source_project.present? && ProtectedBranch.protected?(object.source_project, object.source_branch)
end
|
#user_discussions_count ⇒ Object
257
258
259
260
261
262
263
264
265
|
# File 'app/graphql/types/merge_request_type.rb', line 257
def user_discussions_count
BatchLoader::GraphQL.for(object.id).batch(key: :merge_request_user_discussions_count) do |ids, loader, args|
counts = Note.count_for_collection(ids, 'MergeRequest', 'COUNT(DISTINCT discussion_id) as count').index_by(&:noteable_id)
ids.each do |id|
loader.call(id, counts[id]&.count || 0)
end
end
end
|
#user_notes_count ⇒ Object
247
248
249
250
251
252
253
254
255
|
# File 'app/graphql/types/merge_request_type.rb', line 247
def user_notes_count
BatchLoader::GraphQL.for(object.id).batch(key: :merge_request_user_notes_count) do |ids, loader, args|
counts = Note.count_for_collection(ids, 'MergeRequest').index_by(&:noteable_id)
ids.each do |id|
loader.call(id, counts[id]&.count || 0)
end
end
end
|