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
a195c841
Commit
a195c841
authored
Feb 11, 2020
by
Giorgenes Gelatti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds project_path sorting to package groups api
parent
2b3ac7af
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
2 deletions
+18
-2
ee/app/models/packages/package.rb
ee/app/models/packages/package.rb
+4
-0
ee/changelogs/unreleased/201897-group-packages-list-api-sorting-project-path.yml
...d/201897-group-packages-list-api-sorting-project-path.yml
+5
-0
ee/lib/api/group_packages.rb
ee/lib/api/group_packages.rb
+1
-1
ee/spec/requests/api/group_packages_spec.rb
ee/spec/requests/api/group_packages_spec.rb
+8
-1
No files found.
ee/app/models/packages/package.rb
View file @
a195c841
...
...
@@ -70,6 +70,8 @@ class Packages::Package < ApplicationRecord
scope
:order_type_desc
,
->
{
reorder
(
'package_type DESC'
)
}
scope
:order_project_name
,
->
{
joins
(
:project
).
reorder
(
'projects.name ASC'
)
}
scope
:order_project_name_desc
,
->
{
joins
(
:project
).
reorder
(
'projects.name DESC'
)
}
scope
:order_project_path
,
->
{
joins
(
:project
).
reorder
(
'projects.path ASC, id ASC'
)
}
scope
:order_project_path_desc
,
->
{
joins
(
:project
).
reorder
(
'projects.path DESC, id DESC'
)
}
def
self
.
for_projects
(
projects
)
return
none
unless
projects
.
any?
...
...
@@ -107,6 +109,8 @@ class Packages::Package < ApplicationRecord
when
'type_desc'
then
order_type_desc
when
'project_name_asc'
then
order_project_name
when
'project_name_desc'
then
order_project_name_desc
when
'project_path_asc'
then
order_project_path
when
'project_path_desc'
then
order_project_path_desc
else
order_created_desc
end
...
...
ee/changelogs/unreleased/201897-group-packages-list-api-sorting-project-path.yml
0 → 100644
View file @
a195c841
---
title
:
Adds project_path sorting to group package API
merge_request
:
24833
author
:
type
:
added
ee/lib/api/group_packages.rb
View file @
a195c841
...
...
@@ -21,7 +21,7 @@ module API
end
params
do
use
:pagination
optional
:order_by
,
type:
String
,
values:
%w[created_at name version type]
,
default:
'created_at'
,
optional
:order_by
,
type:
String
,
values:
%w[created_at name version type
project_path
]
,
default:
'created_at'
,
desc:
'Return packages ordered by `created_at`, `name`, `version` or `type` fields.'
optional
:sort
,
type:
String
,
values:
%w[asc desc]
,
default:
'asc'
,
desc:
'Return packages sorted in `asc` or `desc` order.'
...
...
ee/spec/requests/api/group_packages_spec.rb
View file @
a195c841
...
...
@@ -4,7 +4,7 @@ require 'spec_helper'
describe
API
::
GroupPackages
do
let
(
:group
)
{
create
(
:group
,
:public
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
namespace:
group
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
namespace:
group
,
name:
'project A'
)
}
let!
(
:package1
)
{
create
(
:npm_package
,
project:
project
,
version:
'3.1.0'
,
name:
"@
#{
project
.
root_namespace
.
path
}
/foo1"
)
}
let!
(
:package2
)
{
create
(
:nuget_package
,
project:
project
,
version:
'2.0.4'
)
}
let
(
:user
)
{
create
(
:user
)
}
...
...
@@ -54,6 +54,13 @@ describe API::GroupPackages do
it_behaves_like
'package sorting'
,
'type'
do
let
(
:packages
)
{
[
package3
,
package1
,
package2
]
}
end
it_behaves_like
'package sorting'
,
'project_path'
do
let
(
:another_project
)
{
create
(
:project
,
:public
,
namespace:
group
,
name:
'project B'
)
}
let!
(
:package4
)
{
create
(
:npm_package
,
project:
another_project
,
version:
'3.1.0'
,
name:
"@
#{
project
.
root_namespace
.
path
}
/bar"
)
}
let
(
:packages
)
{
[
package1
,
package2
,
package3
,
package4
]
}
end
end
context
'with private group'
do
...
...
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