Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-23 21:09:46 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-23 21:09:46 +0300
commitfdd0b0fd4592c74257980d07878db75705d22192 (patch)
treefcf923555aed86fea3842f1074ec45d2864db20c /lib/gitlab/tree_summary.rb
parent9a9415ab127d5e660c09113238a6fb0a895218e9 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/tree_summary.rb')
-rw-r--r--lib/gitlab/tree_summary.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/gitlab/tree_summary.rb b/lib/gitlab/tree_summary.rb
index 5df53b5adde..724341c9cee 100644
--- a/lib/gitlab/tree_summary.rb
+++ b/lib/gitlab/tree_summary.rb
@@ -6,6 +6,9 @@ module Gitlab
include ::Gitlab::Utils::StrongMemoize
+ CACHE_EXPIRE_IN = 1.hour
+ MAX_OFFSET = 2**31
+
attr_reader :commit, :project, :path, :offset, :limit
attr_reader :resolved_commits
@@ -16,7 +19,7 @@ module Gitlab
@project = project
@path = params.fetch(:path, nil).presence
- @offset = params.fetch(:offset, 0).to_i
+ @offset = [params.fetch(:offset, 0).to_i, MAX_OFFSET].min
@limit = (params.fetch(:limit, 25) || 25).to_i
# Ensure that if multiple tree entries share the same last commit, they share
@@ -43,6 +46,17 @@ module Gitlab
[summary, commits]
end
+ def fetch_logs
+ cache_key = ['projects', project.id, 'logs', commit.id, path, offset]
+ Rails.cache.fetch(cache_key, expires_in: CACHE_EXPIRE_IN) do
+ logs, _ = summarize
+
+ new_offset = next_offset if more?
+
+ [logs.as_json, new_offset]
+ end
+ end
+
# Does the tree contain more entries after the given offset + limit?
def more?
all_contents[next_offset].present?