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
864e5773
Commit
864e5773
authored
9 years ago
by
Giovanne Marcelo
Browse files
Options
Downloads
Patches
Plain Diff
Fixing learning objects topics
parent
dfa0d152
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/services/topics_importer.rb
+10
-5
10 additions, 5 deletions
app/services/topics_importer.rb
with
10 additions
and
5 deletions
app/services/topics_importer.rb
+
10
−
5
View file @
864e5773
...
...
@@ -9,25 +9,30 @@ class TopicsImporter
def
import
learning_objects
=
[]
@items
.
each
do
|
learning_object
|
lo_topics
=
parse_topics
(
learning_object
.
get_metadata_values_of
"dc.subject.category"
)
lo_topics
.
each_with_index
do
|
topic_name
,
i
|
lo_topics
.
each
do
|
topic_name
|
topic
=
@@topics
[
topic_name
]
if
!
topic_exists?
topic_name
topic
=
Topic
.
where
(
name:
topic_name
).
new
create_relations
(
topic_name
)
end
topic
.
learning_objects
<<
learning_object
create_relations
(
topic_name
)
learning_object
.
topics
<<
topic
@@topics
[
topic_name
]
=
topic
end
learning_objects
<<
learning_object
separate_relations
()
end
Topic
.
import
@@topics
.
values
,
recursive:
true
Topic
.
import
@@topics
.
values
LearningObject
.
import
learning_objects
import_topics_relations
()
end
...
...
@@ -51,7 +56,7 @@ class TopicsImporter
unless
relation
.
nil?
||
@@topics_relations
[
i
-
1
].
nil?
parent_id
=
Topic
.
find_by_name
(
@@topics_relations
[
i
-
1
]).
id
child_id
=
Topic
.
find_by_name
(
relation
).
id
unless
TopicRelationship
.
exists?
(
parent_id:
parent_id
,
child_id:
child_id
)
||
i
==
0
unless
TopicRelationship
.
exists?
(
parent_id:
parent_id
,
child_id:
child_id
)
relations
.
push
TopicRelationship
.
where
(
parent_id:
parent_id
,
child_id:
child_id
).
new
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