This commit is contained in:
@@ -39,18 +39,23 @@ class TagVersionsController < ApplicationController
|
||||
cur_aliases = split_values(row.aliases)
|
||||
prev_aliases = split_values(row.attributes['prev_aliases'])
|
||||
|
||||
cur_parent_tags =
|
||||
TagRepr.many(
|
||||
Tag
|
||||
.includes(:tag_name, :materials, { tag_name: :wiki_page })
|
||||
.where(id: split_parent_tag_ids(row.parent_tag_ids))
|
||||
.to_a)
|
||||
prev_parent_tags =
|
||||
TagRepr.many(
|
||||
Tag
|
||||
.includes(:tag_name, :materials, { tag_name: :wiki_page })
|
||||
.where(id: split_parent_tag_ids(row.attributes['prev_parent_tag_ids']))
|
||||
.to_a)
|
||||
cur_parent_tag_ids = split_parent_tag_ids(row.parent_tag_ids)
|
||||
prev_parent_tag_ids = split_parent_tag_ids(row.attributes['prev_parent_tag_ids'])
|
||||
|
||||
all_parent_tag_ids = (cur_parent_tag_ids | prev_parent_tag_ids)
|
||||
|
||||
tags_by_id =
|
||||
Tag
|
||||
.includes(:tag_name, :materials, { tag_name: :wiki_page })
|
||||
.where(id: all_parent_tag_ids)
|
||||
.index_by(&:id)
|
||||
|
||||
parent_tags =
|
||||
build_version_values(cur_parent_tag_ids, prev_parent_tag_ids, key: :tag_id)
|
||||
.map do |h|
|
||||
{ tag: TagRepr.base(tags_by_id[h[:tag_id]]),
|
||||
type: h[:type] }
|
||||
end
|
||||
|
||||
{ tag_id: row.tag_id,
|
||||
version_no: row.version_no,
|
||||
@@ -58,7 +63,7 @@ class TagVersionsController < ApplicationController
|
||||
name: { current: row.name, prev: row.attributes['prev_name'] },
|
||||
category: { current: row.category, prev: row.attributes['prev_category'] },
|
||||
aliases: build_version_values(cur_aliases, prev_aliases, key: :name),
|
||||
parent_tags: build_version_values(cur_parent_tags, prev_parent_tags, key: :tag),
|
||||
parent_tags:,
|
||||
created_at: row.created_at.iso8601,
|
||||
created_by_user: row.created_by_user_id &&
|
||||
{ id: row.created_by_user_id,
|
||||
|
||||
Reference in New Issue
Block a user