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
f01bbcb2
Commit
f01bbcb2
authored
Jul 24, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move FileDownloadDispatchWorker under the Geo namespace
parent
6e56083e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
47 deletions
+49
-47
app/workers/geo/file_download_dispatch_worker.rb
app/workers/geo/file_download_dispatch_worker.rb
+47
-0
app/workers/geo_file_download_dispatch_worker.rb
app/workers/geo_file_download_dispatch_worker.rb
+0
-45
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+1
-1
spec/workers/geo/file_download_dispatch_worker_spec.rb
spec/workers/geo/file_download_dispatch_worker_spec.rb
+1
-1
No files found.
app/workers/geo/file_download_dispatch_worker.rb
0 → 100644
View file @
f01bbcb2
module
Geo
class
FileDownloadDispatchWorker
<
Geo
::
BaseSchedulerWorker
private
def
schedule_job
(
object_db_id
,
object_type
)
job_id
=
GeoFileDownloadWorker
.
perform_async
(
object_type
,
object_db_id
)
{
id:
object_db_id
,
type:
object_type
,
job_id:
job_id
}
if
job_id
end
def
load_pending_resources
lfs_object_ids
=
find_lfs_object_ids
(
db_retrieve_batch_size
)
objects_ids
=
find_object_ids
(
db_retrieve_batch_size
)
interleave
(
lfs_object_ids
,
objects_ids
)
end
def
find_object_ids
(
limit
)
downloaded_ids
=
find_downloaded_ids
([
:attachment
,
:avatar
,
:file
])
Upload
.
where
.
not
(
id:
downloaded_ids
)
.
order
(
created_at: :desc
)
.
limit
(
limit
)
.
pluck
(
:id
,
:uploader
)
.
map
{
|
id
,
uploader
|
[
id
,
uploader
.
sub
(
/Uploader\z/
,
''
).
downcase
]
}
end
def
find_lfs_object_ids
(
limit
)
downloaded_ids
=
find_downloaded_ids
([
:lfs
])
LfsObject
.
where
.
not
(
id:
downloaded_ids
)
.
order
(
created_at: :desc
)
.
limit
(
limit
)
.
pluck
(
:id
)
.
map
{
|
id
|
[
id
,
:lfs
]
}
end
def
find_downloaded_ids
(
file_types
)
downloaded_ids
=
Geo
::
FileRegistry
.
where
(
file_type:
file_types
).
pluck
(
:file_id
)
(
downloaded_ids
+
scheduled_file_ids
(
file_types
)).
uniq
end
def
scheduled_file_ids
(
types
)
scheduled_jobs
.
select
{
|
data
|
types
.
include?
(
data
[
:type
])
}.
map
{
|
data
|
data
[
:id
]
}
end
end
end
app/workers/geo_file_download_dispatch_worker.rb
deleted
100644 → 0
View file @
6e56083e
class
GeoFileDownloadDispatchWorker
<
Geo
::
BaseSchedulerWorker
private
def
schedule_job
(
object_db_id
,
object_type
)
job_id
=
GeoFileDownloadWorker
.
perform_async
(
object_type
,
object_db_id
)
{
id:
object_db_id
,
type:
object_type
,
job_id:
job_id
}
if
job_id
end
def
load_pending_resources
lfs_object_ids
=
find_lfs_object_ids
(
db_retrieve_batch_size
)
objects_ids
=
find_object_ids
(
db_retrieve_batch_size
)
interleave
(
lfs_object_ids
,
objects_ids
)
end
def
find_object_ids
(
limit
)
downloaded_ids
=
find_downloaded_ids
([
:attachment
,
:avatar
,
:file
])
Upload
.
where
.
not
(
id:
downloaded_ids
)
.
order
(
created_at: :desc
)
.
limit
(
limit
)
.
pluck
(
:id
,
:uploader
)
.
map
{
|
id
,
uploader
|
[
id
,
uploader
.
sub
(
/Uploader\z/
,
''
).
downcase
]
}
end
def
find_lfs_object_ids
(
limit
)
downloaded_ids
=
find_downloaded_ids
([
:lfs
])
LfsObject
.
where
.
not
(
id:
downloaded_ids
)
.
order
(
created_at: :desc
)
.
limit
(
limit
)
.
pluck
(
:id
)
.
map
{
|
id
|
[
id
,
:lfs
]
}
end
def
find_downloaded_ids
(
file_types
)
downloaded_ids
=
Geo
::
FileRegistry
.
where
(
file_type:
file_types
).
pluck
(
:file_id
)
(
downloaded_ids
+
scheduled_file_ids
(
file_types
)).
uniq
end
def
scheduled_file_ids
(
types
)
scheduled_jobs
.
select
{
|
data
|
types
.
include?
(
data
[
:type
])
}.
map
{
|
data
|
data
[
:id
]
}
end
end
config/initializers/1_settings.rb
View file @
f01bbcb2
...
@@ -412,7 +412,7 @@ Settings.cron_jobs['geo_repository_sync_worker']['cron'] ||= '*/5 * * * *'
...
@@ -412,7 +412,7 @@ Settings.cron_jobs['geo_repository_sync_worker']['cron'] ||= '*/5 * * * *'
Settings
.
cron_jobs
[
'geo_repository_sync_worker'
][
'job_class'
]
||=
'GeoRepositorySyncWorker'
Settings
.
cron_jobs
[
'geo_repository_sync_worker'
][
'job_class'
]
||=
'GeoRepositorySyncWorker'
Settings
.
cron_jobs
[
'geo_file_download_dispatch_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'geo_file_download_dispatch_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'geo_file_download_dispatch_worker'
][
'cron'
]
||=
'5 * * * *'
Settings
.
cron_jobs
[
'geo_file_download_dispatch_worker'
][
'cron'
]
||=
'5 * * * *'
Settings
.
cron_jobs
[
'geo_file_download_dispatch_worker'
][
'job_class'
]
||=
'GeoFileDownloadDispatchWorker'
Settings
.
cron_jobs
[
'geo_file_download_dispatch_worker'
][
'job_class'
]
||=
'Geo
::
FileDownloadDispatchWorker'
Settings
.
cron_jobs
[
'import_export_project_cleanup_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'import_export_project_cleanup_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'import_export_project_cleanup_worker'
][
'cron'
]
||=
'0 * * * *'
Settings
.
cron_jobs
[
'import_export_project_cleanup_worker'
][
'cron'
]
||=
'0 * * * *'
Settings
.
cron_jobs
[
'import_export_project_cleanup_worker'
][
'job_class'
]
=
'ImportExportProjectCleanupWorker'
Settings
.
cron_jobs
[
'import_export_project_cleanup_worker'
][
'job_class'
]
=
'ImportExportProjectCleanupWorker'
...
...
spec/workers/geo
_
file_download_dispatch_worker_spec.rb
→
spec/workers/geo
/
file_download_dispatch_worker_spec.rb
View file @
f01bbcb2
require
'spec_helper'
require
'spec_helper'
describe
GeoFileDownloadDispatchWorker
do
describe
Geo
::
FileDownloadDispatchWorker
do
before
do
before
do
@primary
=
create
(
:geo_node
,
:primary
,
host:
'primary-geo-node'
)
@primary
=
create
(
:geo_node
,
:primary
,
host:
'primary-geo-node'
)
@secondary
=
create
(
:geo_node
,
:current
)
@secondary
=
create
(
:geo_node
,
:current
)
...
...
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