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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
b85e4d3c
Commit
b85e4d3c
authored
Jan 14, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move issues sort logic to Issuable concern
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
adf6ee09
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
15 deletions
+13
-15
app/contexts/issues/list_context.rb
app/contexts/issues/list_context.rb
+1
-15
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+12
-0
No files found.
app/contexts/issues/list_context.rb
View file @
b85e4d3c
...
...
@@ -31,23 +31,9 @@ module Issues
end
# Sort by :sort param
@issues
=
sort
(
@issues
,
params
[
:sort
])
@issues
=
@issues
.
sort
(
params
[
:sort
])
@issues
end
private
def
sort
(
issues
,
condition
)
case
condition
when
'newest'
then
issues
.
except
(
:order
).
order
(
'created_at DESC'
)
when
'oldest'
then
issues
.
except
(
:order
).
order
(
'created_at ASC'
)
when
'recently_updated'
then
issues
.
except
(
:order
).
order
(
'updated_at DESC'
)
when
'last_updated'
then
issues
.
except
(
:order
).
order
(
'updated_at ASC'
)
when
'milestone_due_soon'
then
issues
.
except
(
:order
).
joins
(
:milestone
).
order
(
"milestones.due_date ASC"
)
when
'milestone_due_later'
then
issues
.
except
(
:order
).
joins
(
:milestone
).
order
(
"milestones.due_date DESC"
)
else
issues
end
end
end
end
app/models/concerns/issuable.rb
View file @
b85e4d3c
...
...
@@ -45,6 +45,18 @@ module Issuable
def
search
(
query
)
where
(
"title like :query"
,
query:
"%
#{
query
}
%"
)
end
def
sort
(
method
)
case
method
.
to_s
when
'newest'
then
reorder
(
'created_at DESC'
)
when
'oldest'
then
reorder
(
'created_at ASC'
)
when
'recently_updated'
then
reorder
(
'updated_at DESC'
)
when
'last_updated'
then
reorder
(
'updated_at ASC'
)
when
'milestone_due_soon'
then
joins
(
:milestone
).
reorder
(
"milestones.due_date ASC"
)
when
'milestone_due_later'
then
joins
(
:milestone
).
reorder
(
"milestones.due_date DESC"
)
else
reorder
(
'created_at DESC'
)
end
end
end
def
today?
...
...
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