diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-24 09:07:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-24 09:07:44 +0300 |
commit | 4dcdd5bebb55bd5522ec180070d4d265e00943b5 (patch) | |
tree | 33760c353dd9dc97d0e5a64b107579b89d9110ea /app | |
parent | 3f29b140ab13fd23ed35e759fd2bb6f41ba788ac (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/commits_helper.rb | 8 | ||||
-rw-r--r-- | app/models/blob.rb | 7 | ||||
-rw-r--r-- | app/services/issues/base_service.rb | 20 | ||||
-rw-r--r-- | app/services/timelogs/create_service.rb | 21 | ||||
-rw-r--r-- | app/services/work_items/callbacks/notes.rb | 14 |
5 files changed, 57 insertions, 13 deletions
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index 6ffef1b612b..6fb6bafb4b6 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -134,7 +134,13 @@ module CommitsHelper def conditionally_paginate_diff_files(diffs, paginate:, page:, per:) if paginate diff_files = diffs.diff_files.to_a - Gitlab::Utils::BatchLoader.clear_key([:repository_blobs, diffs.project.repository]) + project = diffs.project + repo = project.repository + + # While Feature flag increase_diff_file_performance exists, we clear both + Gitlab::Utils::BatchLoader.clear_key([:repository_blobs, repo, Gitlab::Diff::FileCollection::MergeRequestDiffBase.max_blob_size(project)]) + Gitlab::Utils::BatchLoader.clear_key([:repository_blobs, repo, Gitlab::Git::Blob::MAX_DATA_DISPLAY_SIZE]) + Gitlab::Utils::BatchLoader.clear_key([:repository_blobs, repo]) Kaminari.paginate_array(diff_files).page(page).per(per).tap do |diff_files| diff_files.each(&:add_blobs_to_batch_loader) diff --git a/app/models/blob.rb b/app/models/blob.rb index bb8c9345573..c69cd8ac9f4 100644 --- a/app/models/blob.rb +++ b/app/models/blob.rb @@ -94,8 +94,11 @@ class Blob < SimpleDelegator end def self.lazy(repository, commit_id, path, blob_size_limit: Gitlab::Git::Blob::MAX_DATA_DISPLAY_SIZE) - BatchLoader.for([commit_id, path]).batch(key: [:repository_blobs, repository]) do |items, loader, args| - args[:key].last.blobs_at(items, blob_size_limit: blob_size_limit).each do |blob| + key = [:repository_blobs, repository] + key << blob_size_limit if Feature.enabled?(:increase_diff_file_performance, repository.project) + + BatchLoader.for([commit_id, path]).batch(key: key) do |items, loader, args| + args[:key].second.blobs_at(items, blob_size_limit: blob_size_limit).each do |blob| loader.call([blob.commit_id, blob.path], blob) if blob end end diff --git a/app/services/issues/base_service.rb b/app/services/issues/base_service.rb index f564914352b..d87dc013c7f 100644 --- a/app/services/issues/base_service.rb +++ b/app/services/issues/base_service.rb @@ -31,6 +31,16 @@ module Issues Issues::RebalancingWorker.perform_async(nil, *issue.project.self_or_root_group_ids) end + def execute_hooks(issue, action = 'open', old_associations: {}) + issue_data = Gitlab::Lazy.new { hook_data(issue, action, old_associations: old_associations) } + hooks_scope = issue.confidential? ? :confidential_issue_hooks : :issue_hooks + issue.namespace.execute_hooks(issue_data, hooks_scope) + issue.namespace.execute_integrations(issue_data, hooks_scope) + + execute_incident_hooks(issue, issue_data) if issue.work_item_type&.incident? + execute_group_mention_hooks(issue, issue_data) if action == 'open' + end + private # overriding this because IssuableBaseService#constructor_container_arg returns { project: value } @@ -105,16 +115,6 @@ module Issues issue, issue.project, current_user, old_assignees) end - def execute_hooks(issue, action = 'open', old_associations: {}) - issue_data = Gitlab::Lazy.new { hook_data(issue, action, old_associations: old_associations) } - hooks_scope = issue.confidential? ? :confidential_issue_hooks : :issue_hooks - issue.namespace.execute_hooks(issue_data, hooks_scope) - issue.namespace.execute_integrations(issue_data, hooks_scope) - - execute_incident_hooks(issue, issue_data) if issue.work_item_type&.incident? - execute_group_mention_hooks(issue, issue_data) if action == 'open' - end - # We can remove this code after proposal in # https://gitlab.com/gitlab-org/gitlab/-/issues/367550#proposal is updated. def execute_incident_hooks(issue, issue_data) diff --git a/app/services/timelogs/create_service.rb b/app/services/timelogs/create_service.rb index 19428864fa9..f65f9482d76 100644 --- a/app/services/timelogs/create_service.rb +++ b/app/services/timelogs/create_service.rb @@ -37,12 +37,33 @@ module Timelogs note: nil ) + old_associations = { total_time_spent: issuable.total_time_spent } + if !timelog.save error_in_save(timelog) else SystemNoteService.created_timelog(issuable, issuable.project, current_user, timelog) + + issuable_base_service.execute_hooks(issuable, 'update', old_associations: old_associations) + success(timelog) end end + + private + + def issuable_base_service + if issuable.is_a?(Issue) + Issues::BaseService.new( + container: issuable.project, + current_user: current_user + ) + else + MergeRequests::BaseService.new( + project: issuable.project, + current_user: current_user + ) + end + end end end diff --git a/app/services/work_items/callbacks/notes.rb b/app/services/work_items/callbacks/notes.rb new file mode 100644 index 00000000000..a86e2251e81 --- /dev/null +++ b/app/services/work_items/callbacks/notes.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module WorkItems + module Callbacks + class Notes < Base + def before_update + return unless params.present? && params.key?(:discussion_locked) + return unless has_permission?(:set_work_item_metadata) + + work_item.discussion_locked = params[:discussion_locked] + end + end + end +end |