summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Chao <mchao@gitlab.com>2018-09-27 15:22:24 +0800
committerMark Chao <mchao@gitlab.com>2018-11-05 20:09:11 +0800
commit961d43a97b9a971e69b94f0882602746c493e455 (patch)
treede89ba973627c62eb9103a12d316012e338f2408
parent9f7d75fd4eb2ee7717295c0941ac2c093ee1f70e (diff)
downloadgitlab-ce-961d43a97b9a971e69b94f0882602746c493e455.tar.gz
Memorize project to avoid re-query
[skip ci]
-rw-r--r--app/models/deploy_token.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/app/models/deploy_token.rb b/app/models/deploy_token.rb
index 0b2eedf3631..e3524305346 100644
--- a/app/models/deploy_token.rb
+++ b/app/models/deploy_token.rb
@@ -4,6 +4,7 @@ class DeployToken < ActiveRecord::Base
include Expirable
include TokenAuthenticatable
include PolicyActor
+ include Gitlab::Utils::StrongMemoize
add_authentication_token_field :token
AVAILABLE_SCOPES = %i(read_repository read_registry).freeze
@@ -49,7 +50,9 @@ class DeployToken < ActiveRecord::Base
# to a single project, later we're going to extend
# that to be for multiple projects and namespaces.
def project
- projects.first
+ strong_memoize(:project) do
+ projects.first
+ end
end
def expires_at