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
7426318a
Commit
7426318a
authored
Apr 15, 2020
by
David Fernandez
Committed by
James Lopez
Apr 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly apply the prerelease filtering
In particular, for packages that have release and pre release versions.
parent
0dbb8ea4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
8 deletions
+22
-8
ee/app/services/packages/nuget/search_service.rb
ee/app/services/packages/nuget/search_service.rb
+11
-8
ee/changelogs/unreleased/207213-fix-nuget-search.yml
ee/changelogs/unreleased/207213-fix-nuget-search.yml
+5
-0
ee/spec/services/packages/nuget/search_service_spec.rb
ee/spec/services/packages/nuget/search_service_spec.rb
+6
-0
No files found.
ee/app/services/packages/nuget/search_service.rb
View file @
7426318a
...
@@ -8,6 +8,7 @@ module Packages
...
@@ -8,6 +8,7 @@ module Packages
MAX_PER_PAGE
=
30
MAX_PER_PAGE
=
30
MAX_VERSIONS_PER_PACKAGE
=
10
MAX_VERSIONS_PER_PACKAGE
=
10
PRE_RELEASE_VERSION_MATCHING_TERM
=
'%-%'
DEFAULT_OPTIONS
=
{
DEFAULT_OPTIONS
=
{
include_prerelease_versions:
true
,
include_prerelease_versions:
true
,
...
@@ -38,18 +39,20 @@ module Packages
...
@@ -38,18 +39,20 @@ module Packages
# See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/24182#technical-notes
# See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/24182#technical-notes
# and https://docs.microsoft.com/en-us/nuget/api/search-query-service-resource
# and https://docs.microsoft.com/en-us/nuget/api/search-query-service-resource
subquery_name
=
:partition_subquery
subquery_name
=
:partition_subquery
arel_table
=
Arel
::
Table
.
new
(
:partition_subquery
)
column_names
=
Packages
::
Package
.
column_names
.
map
do
|
cn
|
column_names
=
Packages
::
Package
.
column_names
.
map
do
|
cn
|
"
#{
subquery_name
}
.
#{
quote_column_name
(
cn
)
}
"
"
#{
subquery_name
}
.
#{
quote_column_name
(
cn
)
}
"
end
end
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
Packages
::
Package
.
select
(
column_names
.
join
(
','
))
pkgs
=
Packages
::
Package
.
select
(
column_names
.
join
(
','
))
.
from
(
package_names_partition
,
subquery_name
)
.
from
(
package_names_partition
,
subquery_name
)
.
where
(
.
where
(
arel_table
[
:row_number
].
lteq
(
MAX_VERSIONS_PER_PACKAGE
))
"
#{
subquery_name
}
.row_number <= :max_versions_count"
,
max_versions_count:
MAX_VERSIONS_PER_PACKAGE
return
pkgs
if
include_prerelease_versions?
)
# rubocop: enable CodeReuse/ActiveRecord
# we can't use pkgs.without_version_like since we have a custom from
pkgs
.
where
.
not
(
arel_table
[
:version
].
matches
(
PRE_RELEASE_VERSION_MATCHING_TERM
))
end
end
def
package_names_partition
def
package_names_partition
...
@@ -74,7 +77,7 @@ module Packages
...
@@ -74,7 +77,7 @@ module Packages
.
without_nuget_temporary_name
.
without_nuget_temporary_name
.
order_name
.
order_name
.
select_distinct_name
.
select_distinct_name
pkgs
=
pkgs
.
without_version_like
(
'%-%'
)
unless
include_prerelease_versions?
pkgs
=
pkgs
.
without_version_like
(
PRE_RELEASE_VERSION_MATCHING_TERM
)
unless
include_prerelease_versions?
pkgs
=
pkgs
.
search_by_name
(
@search_term
)
if
@search_term
.
present?
pkgs
=
pkgs
.
search_by_name
(
@search_term
)
if
@search_term
.
present?
pkgs
.
page
(
0
)
# we're using a padding
pkgs
.
page
(
0
)
# we're using a padding
.
per
(
per_page
)
.
per
(
per_page
)
...
...
ee/changelogs/unreleased/207213-fix-nuget-search.yml
0 → 100644
View file @
7426318a
---
title
:
'
Nuget
search:
fix
the
prerelease
filtering'
merge_request
:
29482
author
:
type
:
fixed
ee/spec/services/packages/nuget/search_service_spec.rb
View file @
7426318a
...
@@ -97,6 +97,12 @@ describe Packages::Nuget::SearchService do
...
@@ -97,6 +97,12 @@ describe Packages::Nuget::SearchService do
let
(
:include_prerelease_versions
)
{
false
}
let
(
:include_prerelease_versions
)
{
false
}
it
{
expect_search_results
3
,
package_a
,
packages_b
,
packages_c
}
it
{
expect_search_results
3
,
package_a
,
packages_b
,
packages_c
}
context
'when mixed with release versions'
do
let_it_be
(
:package_e_release
)
{
create
(
:nuget_package
,
project:
project
,
name:
'DummyPackageE'
,
version:
'3.2.1'
)
}
it
{
expect_search_results
4
,
package_a
,
packages_b
,
packages_c
,
package_e_release
}
end
end
end
end
end
...
...
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