From 5fd1ad909fc79889f11dd23569ca3b7e112163dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Thu, 22 Feb 2024 21:38:58 +0800 Subject: [PATCH] Fix bug. --- lib/tasks/sync_fgu_personal_data_tasks.rake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/tasks/sync_fgu_personal_data_tasks.rake b/lib/tasks/sync_fgu_personal_data_tasks.rake index 104aa79..ffc2268 100644 --- a/lib/tasks/sync_fgu_personal_data_tasks.rake +++ b/lib/tasks/sync_fgu_personal_data_tasks.rake @@ -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."