feat: 上位タグのバグ修正(#174) #175

Merged
みてるぞ merged 2 commits from feature/174 into main 2025-12-10 20:18:48 +09:00
2 changed files with 22 additions and 2 deletions
Showing only changes of commit 8b4b26065c - Show all commits
@@ -1,7 +1,27 @@
class AddUniqueIndexToTagImplications < ActiveRecord::Migration[8.0] class AddUniqueIndexToTagImplications < ActiveRecord::Migration[8.0]
def change def up
execute <<~SQL
DELETE
ti1
FROM
tag_implications ti1
INNER JOIN
tag_implications ti2
ON
ti1.tag_id = ti2.tag_id
AND ti1.parent_tag_id = ti2.parent_tag_id
AND ti1.id > ti2.id
;
SQL
add_index :tag_implications, [:tag_id, :parent_tag_id], add_index :tag_implications, [:tag_id, :parent_tag_id],
unique: true, unique: true,
name: 'index_tag_implications_on_tag_id_and_parent_tag_id' name: 'index_tag_implications_on_tag_id_and_parent_tag_id'
end end
def down
# NOTE: 重複削除は復元されなぃ.
remove_index :tag_implications,
name: 'index_tag_implications_on_tag_id_and_parent_tag_id'
end
end end
+1 -1
View File
@@ -29,7 +29,7 @@ const renderTagTree = (
return [self, return [self,
...(tag.children ...(tag.children
?.sort ((a, b) => a.name < b.name ? -1 : 1) ?.sort ((a, b) => a.name < b.name ? -1 : 1)
.flatMap (child => renderTagTree (child, nestLevel + 2, key)) ?? [])] .flatMap (child => renderTagTree (child, nestLevel + 1, key)) ?? [])]
} }