Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rescheduled 🗓️
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
c3lingo
rescheduled 🗓️
Commits
7f71a05b
Verified
Commit
7f71a05b
authored
5 months ago
by
tribut
Browse files
Options
Downloads
Patches
Plain Diff
Fix import logic from filedrop
parent
800c6681
Loading
Loading
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/jobs/pretalx/import_job.rb
+9
-3
9 additions, 3 deletions
app/jobs/pretalx/import_job.rb
with
9 additions
and
3 deletions
app/jobs/pretalx/import_job.rb
+
9
−
3
View file @
7f71a05b
...
@@ -147,13 +147,13 @@ module Pretalx
...
@@ -147,13 +147,13 @@ module Pretalx
# Add or update comments
# Add or update comments
data
[
"comments"
]
&
.
each
do
|
comment_data
|
data
[
"comments"
]
&
.
each
do
|
comment_data
|
session
.
filedrop_comments
.
find_or_initialize_by
(
body:
comment_data
[
'body'
]).
tap
do
|
comment
|
session
.
filedrop_comments
.
find_or_initialize_by
(
body:
comment_data
[
'body'
]).
tap
do
|
comment
|
comment
.
orig_created
=
comment_data
[
'created'
]
comment
.
orig_created
=
parse_datetime_or_nil
(
comment_data
[
'
meta'
][
'
created'
]
)
comment
.
save!
comment
.
save!
end
end
end
end
existing_files
=
session
.
filedrop_files
.
pluck
(
:name
,
:checksum
)
existing_files
=
session
.
filedrop_files
.
pluck
(
:name
,
:checksum
)
new_files
=
data
[
'file
drop_files'
]
&
.
pluck
(
'name
'
,
'hash'
)
||
[]
new_files
=
data
[
'file
s'
]
&
.
map
{
|
d
|
[
d
[
'name'
],
d
.
dig
(
'meta
'
,
'hash'
)
]
}
||
[]
# Remove files not in the JSON file
# Remove files not in the JSON file
(
existing_files
-
new_files
).
each
do
|
name
,
checksum
|
(
existing_files
-
new_files
).
each
do
|
name
,
checksum
|
...
@@ -164,11 +164,17 @@ module Pretalx
...
@@ -164,11 +164,17 @@ module Pretalx
data
[
'files'
]
&
.
each
do
|
file_data
|
data
[
'files'
]
&
.
each
do
|
file_data
|
session
.
filedrop_files
.
find_or_initialize_by
(
name:
file_data
[
'name'
],
checksum:
file_data
[
'meta'
][
'hash'
]).
tap
do
|
file
|
session
.
filedrop_files
.
find_or_initialize_by
(
name:
file_data
[
'name'
],
checksum:
file_data
[
'meta'
][
'hash'
]).
tap
do
|
file
|
file
.
size
=
file_data
[
'meta'
][
'size'
]
file
.
size
=
file_data
[
'meta'
][
'size'
]
file
.
orig_created
=
file_data
[
'meta'
][
'created'
]
file
.
orig_created
=
parse_datetime_or_nil
(
file_data
[
'meta'
][
'created'
]
)
file
.
download
(
filedrop_config
[
'url'
]
+
file_data
[
'url'
])
unless
filedrop_config
.
fetch
(
'skip_downloads'
,
false
)
file
.
download
(
filedrop_config
[
'url'
]
+
file_data
[
'url'
])
unless
filedrop_config
.
fetch
(
'skip_downloads'
,
false
)
file
.
save
file
.
save
end
end
end
end
end
end
def
parse_datetime_or_nil
(
datetime_string
)
DateTime
.
iso8601
(
datetime_string
)
rescue
nil
end
end
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment