fix: preserve hashtags when merging duplicate ModuleApps in repair_module

This commit is contained in:
rulingcom 2026-06-26 15:56:01 +08:00
parent 7ec2af1c49
commit 3c3dc6c8d6
1 changed files with 8 additions and 1 deletions

View File

@ -16,6 +16,7 @@ class Admin::PatchfilesController < OrbitAdminController
cats = array_vs.collect{|v| v.categories}.flatten.uniq
tags = array_vs.collect{|v| v.tags}.flatten.uniq
auths = array_vs.collect{|v| v.authorizations}.flatten.uniq
hashtags = array_vs.collect{|v| v.hashtags.to_a}.flatten.uniq
array_vs.reverse.each_with_index do |v,i|
if i == 0
tags = tags.collect do |tag|
@ -33,10 +34,16 @@ class Admin::PatchfilesController < OrbitAdminController
auth.save!
auth
end
hashtags.each do |hashtag|
hashtag.module_app_ids = (hashtag.module_app_ids - array_vs.map(&:id) + [v.id]).uniq
hashtag.save!
end
else
v.tag_ids = []
v.categories = nil
v.authorizations = nil
v.hashtag_ids = []
v.save!
v.destroy
end
end
@ -253,4 +260,4 @@ class Admin::PatchfilesController < OrbitAdminController
end
end
end
end
end