-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2954 from zendesk/grosser/refs
remove indirections from references controller/service/settings
- Loading branch information
Showing
5 changed files
with
24 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
# frozen_string_literal: true | ||
class ReferencesController < ApplicationController | ||
include CurrentProject | ||
CACHE_TTL = Integer(ENV['REFERENCES_CACHE_TTL'].presence || 10.minutes.to_s) | ||
|
||
before_action :authorize_project_deployer! | ||
|
||
def index | ||
@references = ReferencesService.new(@project).find_git_references | ||
render json: @references, root: false | ||
references = Rails.cache.fetch("#{@project.id}_git_references", expires_in: CACHE_TTL) do | ||
repository = @project.repository | ||
(repository.branches + repository.tags).sort_by! { |ref| [-ref.length, ref] }.reverse! | ||
end | ||
render json: references, root: false | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.