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
Léo-Paul Géneau
gitlab-ce
Commits
f5f26f0b
Commit
f5f26f0b
authored
Oct 27, 2018
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add None / Any options to reaction filter in issues / MRs API
parent
31733b6f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
10 deletions
+52
-10
app/finders/issuable_finder.rb
app/finders/issuable_finder.rb
+24
-10
app/models/concerns/awardable.rb
app/models/concerns/awardable.rb
+28
-0
No files found.
app/finders/issuable_finder.rb
View file @
f5f26f0b
...
@@ -244,15 +244,6 @@ class IssuableFinder
...
@@ -244,15 +244,6 @@ class IssuableFinder
params
[
:assignee_username
].
present?
params
[
:assignee_username
].
present?
end
end
def
filter_by_no_assignee?
# Assignee_id takes precedence over assignee_username
[
NONE
,
FILTER_NONE
].
include?
(
params
[
:assignee_id
].
to_s
.
downcase
)
||
params
[
:assignee_username
].
to_s
==
NONE
end
def
filter_by_any_assignee?
params
[
:assignee_id
].
to_s
.
downcase
==
FILTER_ANY
end
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
assignee
def
assignee
return
@assignee
if
defined?
(
@assignee
)
return
@assignee
if
defined?
(
@assignee
)
...
@@ -418,6 +409,15 @@ class IssuableFinder
...
@@ -418,6 +409,15 @@ class IssuableFinder
end
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
def
filter_by_no_assignee?
# Assignee_id takes precedence over assignee_username
[
NONE
,
FILTER_NONE
].
include?
(
params
[
:assignee_id
].
to_s
.
downcase
)
||
params
[
:assignee_username
].
to_s
==
NONE
end
def
filter_by_any_assignee?
params
[
:assignee_id
].
to_s
.
downcase
==
FILTER_ANY
end
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
by_author
(
items
)
def
by_author
(
items
)
if
author
if
author
...
@@ -480,12 +480,26 @@ class IssuableFinder
...
@@ -480,12 +480,26 @@ class IssuableFinder
def
by_my_reaction_emoji
(
items
)
def
by_my_reaction_emoji
(
items
)
if
params
[
:my_reaction_emoji
].
present?
&&
current_user
if
params
[
:my_reaction_emoji
].
present?
&&
current_user
if
filter_by_no_reaction?
items
=
items
.
not_awarded
(
current_user
)
elsif
filter_by_any_reaction?
items
=
items
.
awarded_any
(
current_user
)
else
items
=
items
.
awarded
(
current_user
,
params
[
:my_reaction_emoji
])
items
=
items
.
awarded
(
current_user
,
params
[
:my_reaction_emoji
])
end
end
end
items
items
end
end
def
filter_by_no_reaction?
params
[
:my_reaction_emoji
].
to_s
.
downcase
==
FILTER_NONE
end
def
filter_by_any_reaction?
params
[
:my_reaction_emoji
].
to_s
.
downcase
==
FILTER_ANY
end
def
label_names
def
label_names
if
labels?
if
labels?
params
[
:label_name
].
is_a?
(
String
)
?
params
[
:label_name
].
split
(
','
)
:
params
[
:label_name
]
params
[
:label_name
].
is_a?
(
String
)
?
params
[
:label_name
].
split
(
','
)
:
params
[
:label_name
]
...
...
app/models/concerns/awardable.rb
View file @
f5f26f0b
...
@@ -28,6 +28,34 @@ module Awardable
...
@@ -28,6 +28,34 @@ module Awardable
where
(
sql
,
user_id:
user
.
id
,
name:
name
,
awardable_type:
self
.
name
)
where
(
sql
,
user_id:
user
.
id
,
name:
name
,
awardable_type:
self
.
name
)
end
end
def
awarded_any
(
user
)
sql
=
<<~
EOL
EXISTS (
SELECT TRUE
FROM award_emoji
WHERE user_id = :user_id AND
awardable_type = :awardable_type AND
awardable_id =
#{
self
.
arel_table
.
name
}
.id
)
EOL
where
(
sql
,
user_id:
user
.
id
,
awardable_type:
self
.
name
)
end
def
not_awarded
(
user
)
sql
=
<<~
EOL
NOT EXISTS (
SELECT TRUE
FROM award_emoji
WHERE user_id = :user_id AND
awardable_type = :awardable_type AND
awardable_id =
#{
self
.
arel_table
.
name
}
.id
)
EOL
where
(
sql
,
user_id:
user
.
id
,
awardable_type:
self
.
name
)
end
def
order_upvotes_desc
def
order_upvotes_desc
order_votes_desc
(
AwardEmoji
::
UPVOTE_NAME
)
order_votes_desc
(
AwardEmoji
::
UPVOTE_NAME
)
end
end
...
...
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