This commit is contained in:
邱博亞 2024-02-22 21:38:58 +08:00
parent 47eafeef14
commit 5fd1ad909f
1 changed files with 2 additions and 1 deletions

View File

@ -334,6 +334,7 @@ module FguSyncPlugin
puts "Data found."
puts "Deleting old data"
Honor.where(:member_profile_id => mp.id, :rss2_id.nin => ([nil,''] + data.map{|dt| dt["rss2_id"]})).destroy
Honor.where(:member_profile_id => mp.id, :award_name.in => data.map{|dt| dt["award_name"]}.select{|s| s.present?}).destroy
data.each_with_index do |dt, idx|
rss2_id = dt["rss2_id"]
award_date = self.parse_date(dt["award_date"])
@ -351,7 +352,7 @@ module FguSyncPlugin
end
end
hon = Honor.where(:rss2_id => rss2_id).first
hon_data = {:award_date => award_date, :award_name_translations=> award_name_translations, :country_translations => country_translations, :ranking_translations => ranking_translations, :awarding_body_translations => awarding_body_translations, :awarding_unit_translations => awarding_unit_translations, :year => year, :member_profile => mp, :honor_type => type}
hon_data = {:rss2_id=> rss2_id, :award_date => award_date, :award_name_translations=> award_name_translations, :country_translations => country_translations, :ranking_translations => ranking_translations, :awarding_body_translations => awarding_body_translations, :awarding_unit_translations => awarding_unit_translations, :year => year, :member_profile => mp, :honor_type => type}
if hon.nil?
hon = Honor.create(hon_data)
puts "Saving new Honor."