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
22a4d124
Commit
22a4d124
authored
Mar 22, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use JSON type for sorting parameter (halfway)
parent
98ac988d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
15 deletions
+19
-15
app/finders/pipelines_finder.rb
app/finders/pipelines_finder.rb
+15
-11
lib/api/pipelines.rb
lib/api/pipelines.rb
+4
-4
No files found.
app/finders/pipelines_finder.rb
View file @
22a4d124
...
@@ -108,16 +108,20 @@ class PipelinesFinder
...
@@ -108,16 +108,20 @@ class PipelinesFinder
end
end
def
sort_items
(
items
)
def
sort_items
(
items
)
order_by
=
if
%w[id status ref user_id]
.
include?
(
params
[
:order_by
])
# Allow only indexed columns
return
items
.
order
(
id: :desc
)
unless
params
[
:sort
].
present?
params
[
:order_by
]
params
[
:sort
].
each
do
|
s
|
else
order_by
=
if
%w[id status ref user_id]
.
include?
(
s
[
'order_by'
])
# Allow only indexed columns
:id
s
[
'order_by'
]
end
else
sort
=
if
params
[
:sort
]
=~
/\A(ASC|DESC)\z/i
:id
params
[
:sort
]
end
else
sort
=
if
s
[
'asc_desc'
]
=~
/\A(ASC|DESC)\z/i
:desc
s
[
'asc_desc'
]
end
else
items
.
order
(
order_by
=>
sort
)
:desc
end
items
=
items
.
order
(
order_by
=>
sort
)
end
items
end
end
end
end
lib/api/pipelines.rb
View file @
22a4d124
...
@@ -22,10 +22,10 @@ module API
...
@@ -22,10 +22,10 @@ module API
optional
:yaml_errors
,
type:
Boolean
,
desc:
'If true, returns only yaml error pipelines'
optional
:yaml_errors
,
type:
Boolean
,
desc:
'If true, returns only yaml error pipelines'
optional
:name
,
type:
String
,
desc:
'The name of user who triggered pipelines'
optional
:name
,
type:
String
,
desc:
'The name of user who triggered pipelines'
optional
:username
,
type:
String
,
desc:
'The username of user who triggered pipelines'
optional
:username
,
type:
String
,
desc:
'The username of user who triggered pipelines'
optional
:
order_by
,
type:
String
,
values:
%w[id status ref user_id]
,
default:
'id'
,
optional
:
sort
,
type:
JSON
,
desc:
'order_by and asc_desc'
do
desc:
'The order_by which is combined with a sort'
requires
:order_by
,
type:
String
,
values:
%w[id status ref user_id]
optional
:sort
,
type:
String
,
values:
%w[asc desc]
,
default:
'desc'
,
requires
:asc_desc
,
type:
String
,
values:
%w[asc desc]
desc:
'The sort method which is combined with an order_by'
end
end
end
get
':id/pipelines'
do
get
':id/pipelines'
do
authorize!
:read_pipeline
,
user_project
authorize!
:read_pipeline
,
user_project
...
...
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