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
928acba4
Commit
928acba4
authored
Oct 17, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use keyword arguments on Sortable#highest_label_priority
parent
8379fbcd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
8 deletions
+19
-8
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+8
-3
app/models/concerns/sortable.rb
app/models/concerns/sortable.rb
+4
-4
app/models/todo.rb
app/models/todo.rb
+7
-1
No files found.
app/models/concerns/issuable.rb
View file @
928acba4
...
...
@@ -145,9 +145,14 @@ module Issuable
end
def
order_labels_priority
(
excluded_labels:
[])
condition_field
=
"
#{
table_name
}
.id"
project_field
=
"
#{
table_name
}
.project_id"
highest_priority
=
highest_label_priority
(
name
,
project_field
,
condition_field
,
excluded_labels:
excluded_labels
).
to_sql
params
=
{
target_type:
name
,
target_column:
"
#{
table_name
}
.id"
,
project_column:
"
#{
table_name
}
.project_id"
,
excluded_labels:
excluded_labels
}
highest_priority
=
highest_label_priority
(
params
).
to_sql
select
(
"
#{
table_name
}
.*, (
#{
highest_priority
}
) AS highest_priority"
).
group
(
arel_table
[
:id
]).
...
...
app/models/concerns/sortable.rb
View file @
928acba4
...
...
@@ -38,13 +38,13 @@ module Sortable
private
def
highest_label_priority
(
object_types
,
project_field
,
condition_field
,
excluded_labels:
[])
def
highest_label_priority
(
target_type
:,
target_column
:,
project_column
:
,
excluded_labels:
[])
query
=
Label
.
select
(
LabelPriority
.
arel_table
[
:priority
].
minimum
).
left_join_priorities
.
joins
(
:label_links
).
where
(
label_links:
{
target_type:
object_types
}
).
where
(
"label_priorities.project_id =
#{
project_field
}
"
).
where
(
"label_links.target_id =
#{
condition_field
}
"
).
where
(
"label_priorities.project_id =
#{
project_column
}
"
).
where
(
label_links:
{
target_type:
target_type
}
).
where
(
"label_links.target_id =
#{
target_column
}
"
).
reorder
(
nil
)
query
.
where
.
not
(
title:
excluded_labels
)
if
excluded_labels
.
present?
...
...
app/models/todo.rb
View file @
928acba4
...
...
@@ -52,7 +52,13 @@ class Todo < ActiveRecord::Base
# Todos with highest priority first then oldest todos
# Need to order by created_at last because of differences on Mysql and Postgres when joining by type "Merge_request/Issue"
def
order_by_labels_priority
highest_priority
=
highest_label_priority
([
"Issue"
,
"MergeRequest"
],
"todos.project_id"
,
"todos.target_id"
).
to_sql
params
=
{
target_type:
[
'Issue'
,
'MergeRequest'
],
target_column:
"todos.target_id"
,
project_column:
"todos.project_id"
}
highest_priority
=
highest_label_priority
(
params
).
to_sql
select
(
"
#{
table_name
}
.*, (
#{
highest_priority
}
) AS highest_priority"
).
order
(
Gitlab
::
Database
.
nulls_last_order
(
'highest_priority'
,
'ASC'
)).
...
...
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