Skip to content

Commit fb82dc7

Browse files
authored
fix: update CSV file generators for topic tags (#645)
2 parents 0f4fe78 + f0dd4e9 commit fb82dc7

4 files changed

Lines changed: 17 additions & 17 deletions

File tree

app/services/csv_generator/tag_details.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ def headers
1313
end
1414

1515
def scope
16-
language.topics.active.includes(:tags)
17-
.flat_map { |topic| topic.tags_on(language.code.to_sym) }
18-
.uniq
19-
.map do |tag|
20-
[
21-
tag.id,
22-
tag.name,
23-
]
24-
end
16+
language.topics.active.includes(taggings: :tag)
17+
.flat_map do |topic|
18+
topic.taggings.map do |tagging|
19+
[
20+
tagging.tag.id,
21+
tagging.tag.name,
22+
]
23+
end
24+
end.uniq
2525
end
2626
end

app/services/csv_generator/topic_tags.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ def headers
1313
end
1414

1515
def scope
16-
language.topics.active.includes(:tags)
16+
language.topics.active.includes(taggings: :tag)
1717
.flat_map do |topic|
18-
topic.tags_on(language.code.to_sym).map do |tag|
18+
topic.taggings.map do |tagging|
1919
[
2020
topic.id,
21-
tag.id,
21+
tagging.tag.id,
2222
]
2323
end
24-
end
24+
end.uniq
2525
end
2626
end

spec/services/csv_generator/tag_details_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
let!(:topic) { create(:topic, :tagged, language:) }
1515
let(:data) do
1616
header.tap do |csv|
17-
topic.tags_on(language.code.to_sym).each do |tag|
18-
csv << "#{tag.id},#{tag.name}\n"
17+
topic.taggings.each do |tagging|
18+
csv << "#{tagging.tag.id},#{tagging.tag.name}\n"
1919
end
2020
end
2121
end

spec/services/csv_generator/topic_tags_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
let!(:topic) { create(:topic, :tagged, language:) }
1515
let(:data) do
1616
header.tap do |csv|
17-
topic.tags_on(language.code.to_sym).each do |tag|
18-
csv << "#{topic.id},#{tag.id}\n"
17+
topic.taggings.each do |tagging|
18+
csv << "#{topic.id},#{tagging.tag.id}\n"
1919
end
2020
end
2121
end

0 commit comments

Comments
 (0)