Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
bfce7349
Commit
bfce7349
authored
Jun 20, 2016
by
Paco Guzman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cache Participable#participants in instance variable
parent
f90c8c62
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
0 deletions
+21
-0
CHANGELOG
CHANGELOG
+1
-0
app/models/concerns/participable.rb
app/models/concerns/participable.rb
+10
-0
spec/models/concerns/participable_spec.rb
spec/models/concerns/participable_spec.rb
+10
-0
No files found.
CHANGELOG
View file @
bfce7349
...
...
@@ -135,6 +135,7 @@ v 8.9.0 (unreleased)
- Update tanuki logo highlight/loading colors
- Remove explicit Gitlab::Metrics.action assignments, are already automatic.
- Use Git cached counters for branches and tags on project page
- Cache participable participants in an instance variable.
- Filter parameters for request_uri value on instrumented transactions.
- Remove duplicated keys add UNIQUE index to keys fingerprint column
- ExtractsPath get ref_names from repository cache, if not there access git.
...
...
app/models/concerns/participable.rb
View file @
bfce7349
...
...
@@ -53,6 +53,16 @@ module Participable
#
# Returns an Array of User instances.
def
participants
(
current_user
=
nil
)
@participants
||=
Hash
.
new
do
|
hash
,
user
|
hash
[
user
]
=
raw_participants
(
user
)
end
@participants
[
current_user
]
end
private
def
raw_participants
(
current_user
=
nil
)
current_user
||=
author
ext
=
Gitlab
::
ReferenceExtractor
.
new
(
project
,
current_user
)
participants
=
Set
.
new
...
...
spec/models/concerns/participable_spec.rb
View file @
bfce7349
...
...
@@ -37,6 +37,16 @@ describe Participable, models: true do
expect
(
participants
).
to
include
(
user3
)
end
it
'caches the raw list of participants'
do
instance
=
model
.
new
user1
=
build
(
:user
)
expect
(
instance
).
to
receive
(
:raw_participants
).
once
instance
.
participants
(
user1
)
instance
.
participants
(
user1
)
end
it
'supports attributes returning another Participable'
do
other_model
=
Class
.
new
{
include
Participable
}
...
...
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