Skip to content
Snippets Groups Projects
Commit dfa0d152 authored by Giovanne Marcelo's avatar Giovanne Marcelo
Browse files

Fixing repeated topics relationships

parent 79f1fdc7
No related branches found
No related tags found
No related merge requests found
......@@ -9,26 +9,25 @@ class TopicsImporter
def import
relations = []
@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|
next if topic_exists? topic_name
if !topic_exists? topic_name
topic = Topic.where(name: topic_name).new
create_relations(topic_name)
end
topic = Topic.where(name: topic_name).new
topic.learning_objects << learning_object
create_relations(lo_topics[i - 1], topic_name) unless i == 0
@@topics[topic_name] = topic
end
separate_relations()
end
Topic.import @@topics.values
Topic.import @@topics.values, recursive: true
import_topics_relations()
end
......@@ -36,9 +35,8 @@ class TopicsImporter
private
def create_relations parent_name, child_name
@@topics_relations.push(parent_name)
@@topics_relations.push(child_name)
def create_relations topic_name
@@topics_relations << topic_name
end
def separate_relations
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment