BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
fee3fe72
Commit
fee3fe72
authored
May 18, 2018
by
Rémy Coutable
Committed by
Filipa Lacerda
May 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge branch 'memoize-database-version' into 'master'
Memoize Gitlab::Database.version See merge request gitlab-org/gitlab-ce!19021
parent
5e39c6d7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
1 deletion
+20
-1
memoize-database-version.yml
changelogs/unreleased/memoize-database-version.yml
+5
-0
database.rb
lib/gitlab/database.rb
+1
-1
database_spec.rb
spec/lib/gitlab/database_spec.rb
+14
-0
No files found.
changelogs/unreleased/memoize-database-version.yml
0 → 100644
View file @
fee3fe72
---
title
:
Memoize Gitlab::Database.version
merge_request
:
author
:
type
:
performance
lib/gitlab/database.rb
View file @
fee3fe72
...
...
@@ -43,7 +43,7 @@ module Gitlab
end
def
self
.
version
database_version
.
match
(
/\A(?:PostgreSQL |)([^\s]+).*\z/
)[
1
]
@version
||=
database_version
.
match
(
/\A(?:PostgreSQL |)([^\s]+).*\z/
)[
1
]
end
def
self
.
join_lateral_supported?
...
...
spec/lib/gitlab/database_spec.rb
View file @
fee3fe72
...
...
@@ -32,6 +32,12 @@ describe Gitlab::Database do
end
describe
'.version'
do
around
do
|
example
|
described_class
.
instance_variable_set
(
:@version
,
nil
)
example
.
run
described_class
.
instance_variable_set
(
:@version
,
nil
)
end
context
"on mysql"
do
it
"extracts the version number"
do
allow
(
described_class
).
to
receive
(
:database_version
)
...
...
@@ -49,6 +55,14 @@ describe Gitlab::Database do
expect
(
described_class
.
version
).
to
eq
'9.4.4'
end
end
it
'memoizes the result'
do
count
=
ActiveRecord
::
QueryRecorder
.
new
{
2
.
times
{
described_class
.
version
}
}
.
count
expect
(
count
).
to
eq
(
1
)
end
end
describe
'.join_lateral_supported?'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment