Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cleaning-portalmec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Richard Fernando Heise Ferreira
cleaning-portalmec
Commits
44eba709
Commit
44eba709
authored
9 years ago
by
Mateus Rambo Strey
Browse files
Options
Downloads
Patches
Plain Diff
speedup dspace:import_items
parent
0691e281
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/models/learning_object.rb
+1
-1
1 addition, 1 deletion
app/models/learning_object.rb
app/services/dspace/learning_object_importer.rb
+13
-3
13 additions, 3 deletions
app/services/dspace/learning_object_importer.rb
lib/tasks/dspace.rake
+2
-2
2 additions, 2 deletions
lib/tasks/dspace.rake
with
16 additions
and
6 deletions
app/models/learning_object.rb
+
1
−
1
View file @
44eba709
...
...
@@ -9,7 +9,7 @@ class LearningObject < ActiveRecord::Base
has_many
:collection_items
,
as: :collectionable
has_many
:collections
,
through: :collection_items
has_many
:complaints
has_many
:attachments
,
class_name:
'LearningObject::Attachment'
,
dependent: :destroy
has_many
:attachments
,
class_name:
'LearningObject::Attachment'
,
dependent: :destroy
,
autosave:
true
# autosave to allow import
belongs_to
:publisher
,
polymorphic:
true
belongs_to
:language
...
...
This diff is collapsed.
Click to expand it.
app/services/dspace/learning_object_importer.rb
+
13
−
3
View file @
44eba709
...
...
@@ -5,14 +5,24 @@ class Dspace::LearningObjectImporter
end
def
import
items
=
[]
@items
.
each
do
|
item
|
next
if
item_exists?
item
learning_object
=
LearningObjectBuilder
.
build_from_dspace
item
create_attachments
learning_object
,
item
.
bit_streams
if
learning_object
.
save
learning_object
=
LearningObjectBuilder
.
build_from_dspace
(
item
)
next
if
learning_object
.
blank?
create_attachments
(
learning_object
,
item
.
bit_streams
)
items
<<
learning_object
yield
(
learning_object
)
if
block_given?
end
LearningObject
.
import
items
,
recursive:
true
end
private
...
...
@@ -20,7 +30,7 @@ class Dspace::LearningObjectImporter
def
create_attachments
(
learning_object
,
bitstreams
)
bitstreams
=
JSON
.
parse
bitstreams
if
bitstreams
.
class
==
String
bitstreams
.
each
do
|
bitstream
|
learning_object
.
attachments
.
create
::
Dspace
::
AttachmentMapper
.
call
(
bitstream
)
learning_object
.
attachments
.
new
::
Dspace
::
AttachmentMapper
.
call
(
bitstream
)
end
end
...
...
This diff is collapsed.
Click to expand it.
lib/tasks/dspace.rake
+
2
−
2
View file @
44eba709
...
...
@@ -11,7 +11,7 @@ namespace :dspace do
logger
.
level
=
Log
::
DatabaseLogger
::
CREATE
# Quantity of items fetched on each iteration
limit
=
10
00
limit
=
5
00
# Start point from where items will be fetched
offset
=
0
...
...
@@ -48,7 +48,7 @@ namespace :dspace do
# Initializes new LearningObjects
# and saves them on LearningObjects's repository
importer
=
Dspace
::
LearningObjectImporter
.
new
(
dspace_items
)
importer
.
import
{
|
learning_object
|
logger
.
create
"Imported:
#{
learning_object
.
id_dspace
}
->
#{
learning_object
.
id
}
"
}
importer
.
import
end
end
logger
.
close
...
...
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