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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
300745c6
Commit
300745c6
authored
Aug 20, 2018
by
Mario de la Ossa
Committed by
Jose Vargas
Dec 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bring back asc/desc sort orders for Issues/MRs
parent
60fb3ff6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
23 deletions
+28
-23
app/controllers/concerns/issuable_collections.rb
app/controllers/concerns/issuable_collections.rb
+0
-6
app/models/concerns/awardable.rb
app/models/concerns/awardable.rb
+9
-4
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+19
-13
No files found.
app/controllers/concerns/issuable_collections.rb
View file @
300745c6
...
...
@@ -167,12 +167,6 @@ module IssuableCollections
case
value
when
'id_asc'
then
sort_value_oldest_created
when
'id_desc'
then
sort_value_recently_created
when
'created_asc'
then
sort_value_created_date
when
'created_desc'
then
sort_value_created_date
when
'due_date_asc'
then
sort_value_due_date
when
'due_date_desc'
then
sort_value_due_date
when
'milestone_due_asc'
then
sort_value_milestone
when
'milestone_due_desc'
then
sort_value_milestone
when
'downvotes_asc'
then
sort_value_popularity
when
'downvotes_desc'
then
sort_value_popularity
else
value
...
...
app/models/concerns/awardable.rb
View file @
300745c6
...
...
@@ -43,14 +43,19 @@ module Awardable
end
def
order_upvotes_desc
order_votes_desc
(
AwardEmoji
::
UPVOTE_NAME
)
order_votes
(
AwardEmoji
::
UPVOTE_NAME
,
'DESC'
)
end
def
order_upvotes_asc
order_votes
(
AwardEmoji
::
UPVOTE_NAME
,
'ASC'
)
end
def
order_downvotes_desc
order_votes
_desc
(
AwardEmoji
::
DOWNVOTE_NAME
)
order_votes
(
AwardEmoji
::
DOWNVOTE_NAME
,
'DESC'
)
end
def
order_votes_desc
(
emoji_name
)
# Order votes by emoji, optional sort order param `descending` defaults to true
def
order_votes
(
emoji_name
,
direction
)
awardable_table
=
self
.
arel_table
awards_table
=
AwardEmoji
.
arel_table
...
...
@@ -62,7 +67,7 @@ module Awardable
)
).
join_sources
joins
(
join_clause
).
group
(
awardable_table
[
:id
]).
reorder
(
"COUNT(award_emoji.id)
DESC
"
)
joins
(
join_clause
).
group
(
awardable_table
[
:id
]).
reorder
(
"COUNT(award_emoji.id)
#{
direction
}
"
)
end
end
...
...
app/models/concerns/issuable.rb
View file @
300745c6
...
...
@@ -145,14 +145,20 @@ module Issuable
def
sort_by_attribute
(
method
,
excluded_labels:
[])
sorted
=
case
method
.
to_s
when
'downvotes_desc'
then
order_downvotes_desc
when
'label_priority'
then
order_labels_priority
(
excluded_labels:
excluded_labels
)
when
'milestone'
then
order_milestone_due_asc
when
'milestone_due_asc'
then
order_milestone_due_asc
when
'milestone_due_desc'
then
order_milestone_due_desc
when
'popularity'
then
order_upvotes_desc
when
'priority'
then
order_due_date_and_labels_priority
(
excluded_labels:
excluded_labels
)
when
'upvotes_desc'
then
order_upvotes_desc
when
'downvotes_desc'
then
order_downvotes_desc
when
'label_priority'
then
order_labels_priority
(
excluded_labels:
excluded_labels
)
when
'label_priority_asc'
then
order_labels_priority
(
excluded_labels:
excluded_labels
)
when
'label_priority_desc'
then
order_labels_priority
(
'DESC'
,
excluded_labels:
excluded_labels
)
when
'milestone'
then
order_milestone_due_asc
when
'milestone_due_asc'
then
order_milestone_due_asc
when
'milestone_due_desc'
then
order_milestone_due_desc
when
'popularity'
then
order_upvotes_desc
when
'popularity_desc'
then
order_upvotes_desc
when
'popularity_asc'
then
order_upvotes_asc
when
'priority'
then
order_due_date_and_labels_priority
(
excluded_labels:
excluded_labels
)
when
'priority_asc'
then
order_due_date_and_labels_priority
(
excluded_labels:
excluded_labels
)
when
'priority_desc'
then
order_due_date_and_labels_priority
(
'DESC'
,
excluded_labels:
excluded_labels
)
when
'upvotes_desc'
then
order_upvotes_desc
else
order_by
(
method
)
end
...
...
@@ -160,7 +166,7 @@ module Issuable
sorted
.
with_order_id_desc
end
def
order_due_date_and_labels_priority
(
excluded_labels:
[])
def
order_due_date_and_labels_priority
(
direction
=
'ASC'
,
excluded_labels:
[])
# The order_ methods also modify the query in other ways:
#
# - For milestones, we add a JOIN.
...
...
@@ -177,11 +183,11 @@ module Issuable
order_milestone_due_asc
.
order_labels_priority
(
excluded_labels:
excluded_labels
,
extra_select_columns:
[
milestones_due_date
])
.
reorder
(
Gitlab
::
Database
.
nulls_last_order
(
milestones_due_date
,
'ASC'
),
Gitlab
::
Database
.
nulls_last_order
(
'highest_priority'
,
'ASC'
))
.
reorder
(
Gitlab
::
Database
.
nulls_last_order
(
milestones_due_date
,
direction
),
Gitlab
::
Database
.
nulls_last_order
(
'highest_priority'
,
direction
))
end
def
order_labels_priority
(
excluded_labels:
[],
extra_select_columns:
[])
def
order_labels_priority
(
direction
=
'ASC'
,
excluded_labels:
[],
extra_select_columns:
[])
params
=
{
target_type:
name
,
target_column:
"
#{
table_name
}
.id"
,
...
...
@@ -198,7 +204,7 @@ module Issuable
select
(
select_columns
.
join
(
', '
))
.
group
(
arel_table
[
:id
])
.
reorder
(
Gitlab
::
Database
.
nulls_last_order
(
'highest_priority'
,
'ASC'
))
.
reorder
(
Gitlab
::
Database
.
nulls_last_order
(
'highest_priority'
,
direction
))
end
def
with_label
(
title
,
sort
=
nil
)
...
...
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