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:
Diffstat (limited to 'lib/gitlab/whats_new.rb')
-rw-r--r--lib/gitlab/whats_new.rb26
1 files changed, 19 insertions, 7 deletions
diff --git a/lib/gitlab/whats_new.rb b/lib/gitlab/whats_new.rb
index e95ace2c475..69ccb48c544 100644
--- a/lib/gitlab/whats_new.rb
+++ b/lib/gitlab/whats_new.rb
@@ -2,27 +2,39 @@
module Gitlab
module WhatsNew
- CACHE_DURATION = 1.day
+ CACHE_DURATION = 1.hour
WHATS_NEW_FILES_PATH = Rails.root.join('data', 'whats_new', '*.yml')
private
- def whats_new_most_recent_release_items
- Rails.cache.fetch('whats_new:release_items', expires_in: CACHE_DURATION) do
- file = File.read(most_recent_release_file_path)
+ def whats_new_release_items(page: 1)
+ Rails.cache.fetch(whats_new_items_cache_key(page), expires_in: CACHE_DURATION) do
+ index = page - 1
+ file_path = whats_new_file_paths[index]
+
+ next if file_path.nil?
+
+ file = File.read(file_path)
items = YAML.safe_load(file, permitted_classes: [Date])
items if items.is_a?(Array)
end
rescue => e
- Gitlab::ErrorTracking.track_exception(e, yaml_file_path: most_recent_release_file_path)
+ Gitlab::ErrorTracking.track_exception(e, page: page)
nil
end
- def most_recent_release_file_path
- @most_recent_release_file_path ||= Dir.glob(WHATS_NEW_FILES_PATH).max
+ def whats_new_file_paths
+ @whats_new_file_paths ||= Rails.cache.fetch('whats_new:file_paths', expires_in: CACHE_DURATION) do
+ Dir.glob(WHATS_NEW_FILES_PATH).sort.reverse
+ end
+ end
+
+ def whats_new_items_cache_key(page)
+ filename = /\d*\_\d*\_\d*/.match(whats_new_file_paths&.first)
+ "whats_new:release_items:file-#{filename}:page-#{page}"
end
end
end