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
f0a2c411
Commit
f0a2c411
authored
Jan 17, 2019
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow IssuableFinder to filter by closed_at
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
deca6688
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
0 deletions
+53
-0
app/finders/issuable_finder.rb
app/finders/issuable_finder.rb
+8
-0
app/models/concerns/closed_at_filterable.rb
app/models/concerns/closed_at_filterable.rb
+14
-0
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+1
-0
spec/finders/issues_finder_spec.rb
spec/finders/issues_finder_spec.rb
+30
-0
No files found.
app/finders/issuable_finder.rb
View file @
f0a2c411
...
...
@@ -94,6 +94,7 @@ class IssuableFinder
items
=
by_scope
(
items
)
items
=
by_created_at
(
items
)
items
=
by_updated_at
(
items
)
items
=
by_closed_at
(
items
)
items
=
by_state
(
items
)
items
=
by_group
(
items
)
items
=
by_assignee
(
items
)
...
...
@@ -353,6 +354,13 @@ class IssuableFinder
items
end
def
by_closed_at
(
items
)
items
=
items
.
closed_after
(
params
[
:closed_after
])
if
params
[
:closed_after
].
present?
items
=
items
.
closed_before
(
params
[
:closed_before
])
if
params
[
:closed_before
].
present?
items
end
# rubocop: disable CodeReuse/ActiveRecord
def
by_state
(
items
)
case
params
[
:state
].
to_s
...
...
app/models/concerns/closed_at_filterable.rb
0 → 100644
View file @
f0a2c411
# frozen_string_literal: true
module
ClosedAtFilterable
extend
ActiveSupport
::
Concern
included
do
scope
:closed_before
,
->
(
date
)
{
where
(
scoped_table
[
:closed_at
].
lteq
(
date
))
}
scope
:closed_after
,
->
(
date
)
{
where
(
scoped_table
[
:closed_at
].
gteq
(
date
))
}
def
self
.
scoped_table
arel_table
.
alias
(
table_name
)
end
end
end
app/models/concerns/issuable.rb
View file @
f0a2c411
...
...
@@ -23,6 +23,7 @@ module Issuable
include
Sortable
include
CreatedAtFilterable
include
UpdatedAtFilterable
include
ClosedAtFilterable
# This object is used to gather issuable meta data for displaying
# upvotes, downvotes, notes and closing merge requests count for issues and merge requests
...
...
spec/finders/issues_finder_spec.rb
View file @
f0a2c411
...
...
@@ -416,6 +416,36 @@ describe IssuesFinder do
end
end
context
'filtering by closed_at'
do
let!
(
:closed_issue1
)
{
create
(
:issue
,
project:
project1
,
state: :closed
,
closed_at:
1
.
week
.
ago
)
}
let!
(
:closed_issue2
)
{
create
(
:issue
,
project:
project2
,
state: :closed
,
closed_at:
1
.
week
.
from_now
)
}
let!
(
:closed_issue3
)
{
create
(
:issue
,
project:
project2
,
state: :closed
,
closed_at:
2
.
weeks
.
from_now
)
}
context
'through closed_after'
do
let
(
:params
)
{
{
state: :closed
,
closed_after:
closed_issue3
.
closed_at
}
}
it
'returns issues closed on or after the given date'
do
expect
(
issues
).
to
contain_exactly
(
closed_issue3
)
end
end
context
'through closed_before'
do
let
(
:params
)
{
{
state: :closed
,
closed_before:
closed_issue1
.
closed_at
}
}
it
'returns issues closed on or before the given date'
do
expect
(
issues
).
to
contain_exactly
(
closed_issue1
)
end
end
context
'through closed_after and closed_before'
do
let
(
:params
)
{
{
state: :closed
,
closed_after:
closed_issue2
.
closed_at
,
closed_before:
closed_issue3
.
closed_at
}
}
it
'returns issues closed between the given dates'
do
expect
(
issues
).
to
contain_exactly
(
closed_issue2
,
closed_issue3
)
end
end
end
context
'filtering by reaction name'
do
context
'user searches by no reaction'
do
let
(
:params
)
{
{
my_reaction_emoji:
'None'
}
}
...
...
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