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
472a9a3e
Commit
472a9a3e
authored
Apr 03, 2019
by
Toon Claes
Committed by
Stan Hu
Apr 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the UploadRegistry searchable
Search the Geo Upload registry by path of the actual upload.
parent
b3dfc1da
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
10 deletions
+42
-10
ee/app/models/geo/fdw/upload.rb
ee/app/models/geo/fdw/upload.rb
+13
-0
ee/app/models/geo/upload_registry.rb
ee/app/models/geo/upload_registry.rb
+6
-0
ee/spec/models/geo/upload_registry_spec.rb
ee/spec/models/geo/upload_registry_spec.rb
+19
-10
ee/spec/spec_helper.rb
ee/spec/spec_helper.rb
+4
-0
No files found.
ee/app/models/geo/fdw/upload.rb
View file @
472a9a3e
...
...
@@ -3,6 +3,7 @@
module
Geo
module
Fdw
class
Upload
<
::
Geo
::
BaseFdw
include
Gitlab
::
SQL
::
Pattern
include
ObjectStorable
STORE_COLUMN
=
:store
...
...
@@ -10,6 +11,18 @@ module Geo
self
.
table_name
=
Gitlab
::
Geo
::
Fdw
.
foreign_table_name
(
'uploads'
)
scope
:geo_syncable
,
->
{
with_files_stored_locally
}
class
<<
self
# Searches for a list of uploads based on the query given in `query`.
#
# On PostgreSQL this method uses "ILIKE" to perform a case-insensitive
# search.
#
# query - The search query as a String.
def
search
(
query
)
fuzzy_search
(
query
,
[
:path
])
end
end
end
end
end
ee/app/models/geo/upload_registry.rb
View file @
472a9a3e
...
...
@@ -15,6 +15,12 @@ class Geo::UploadRegistry < Geo::FileRegistry
sti_column
.
in
(
sti_names
)
end
def
self
.
with_search
(
query
)
return
all
if
query
.
nil?
where
(
file_id:
Geo
::
Fdw
::
Upload
.
search
(
query
))
end
def
file
upload
&
.
path
||
s_
(
'Removed %{type} with id %{id}'
)
%
{
type:
file_type
,
id:
file_id
}
end
...
...
ee/spec/models/geo/upload_registry_spec.rb
View file @
472a9a3e
...
...
@@ -2,15 +2,15 @@
require
'spec_helper'
describe
Geo
::
UploadRegistry
,
:geo
do
set
(
:lfs_registry
)
{
create
(
:geo_file_registry
,
:lfs
)
}
set
(
:attachment_registry
)
{
create
(
:geo_file_registry
,
:attachment
,
:with_file
)
}
set
(
:avatar_registry
)
{
create
(
:geo_file_registry
,
:avatar
)
}
set
(
:file_registry
)
{
create
(
:geo_file_registry
,
:file
)
}
set
(
:namespace_file_registry
)
{
create
(
:geo_file_registry
,
:namespace_file
)
}
set
(
:personal_file_registry
)
{
create
(
:geo_file_registry
,
:personal_file
)
}
set
(
:favicon_registry
)
{
create
(
:geo_file_registry
,
:favicon
)
}
set
(
:import_export_registry
)
{
create
(
:geo_file_registry
,
:import_export
)
}
describe
Geo
::
UploadRegistry
,
:geo
,
:delete
do
let!
(
:lfs_registry
)
{
create
(
:geo_file_registry
,
:lfs
)
}
let!
(
:attachment_registry
)
{
create
(
:geo_file_registry
,
:attachment
,
:with_file
)
}
let!
(
:avatar_registry
)
{
create
(
:geo_file_registry
,
:avatar
)
}
let!
(
:file_registry
)
{
create
(
:geo_file_registry
,
:file
)
}
let!
(
:namespace_file_registry
)
{
create
(
:geo_file_registry
,
:namespace_file
)
}
let!
(
:personal_file_registry
)
{
create
(
:geo_file_registry
,
:personal_file
)
}
let!
(
:favicon_registry
)
{
create
(
:geo_file_registry
,
:favicon
)
}
let!
(
:import_export_registry
)
{
create
(
:geo_file_registry
,
:import_export
)
}
it
'finds all upload registries'
do
expected
=
[
attachment_registry
,
...
...
@@ -28,9 +28,18 @@ describe Geo::UploadRegistry, :geo do
expect
(
described_class
.
find
(
attachment_registry
.
id
).
upload
).
to
be_an_instance_of
(
Upload
)
end
describe
'.with_search'
,
:geo_fdw
do
it
'searches registries on path'
do
upload
=
create
(
:upload
,
path:
'uploads/-/system/project/avatar/my-awesome-avatar.png'
)
upload_registry
=
create
(
:geo_upload_registry
,
file_id:
upload
.
id
,
file_type: :avatar
)
expect
(
described_class
.
with_search
(
'awesome-avatar'
)).
to
match_ids
(
upload_registry
)
end
end
describe
'#file'
do
it
'returns the path of the upload of a registry'
do
registry
=
create
(
:geo_upload_registry
,
:
avatar
,
:with_file
)
registry
=
create
(
:geo_upload_registry
,
:
file
,
:with_file
)
expect
(
registry
.
file
).
to
eq
(
'uploads/-/system/project/avatar/avatar.jpg'
)
end
...
...
ee/spec/spec_helper.rb
View file @
472a9a3e
...
...
@@ -18,4 +18,8 @@ RSpec.configure do |config|
config
.
around
(
:each
,
:geo_tracking_db
)
do
|
example
|
example
.
run
if
Gitlab
::
Geo
.
geo_database_configured?
end
config
.
around
(
:each
,
:geo_fdw
)
do
|
example
|
example
.
run
if
Gitlab
::
Geo
::
Fdw
.
enabled?
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