From f235436e19caf10a18b2bd531a259a5c1842a762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Wed, 25 Sep 2024 22:10:03 +0800 Subject: [PATCH] Fix experience missing rss2_id. --- lib/tasks/sync_fgu_personal_data_tasks.rake | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/tasks/sync_fgu_personal_data_tasks.rake b/lib/tasks/sync_fgu_personal_data_tasks.rake index b80b607..fa5a5ad 100644 --- a/lib/tasks/sync_fgu_personal_data_tasks.rake +++ b/lib/tasks/sync_fgu_personal_data_tasks.rake @@ -237,10 +237,13 @@ module FguSyncPlugin if type.nil? type = ExperienceType.create(:title_translations => self.localize_data(dt["emp_type"])) end + else + type = nil end + Experience.where(:rss2_id => nil, :organizationt_title=> dt["organization_title"], :job_title => dt["job_title"], :member_profile => mp, :experience_type => type).destroy # destroy old data exp = Experience.where(:rss2_id => rss2_id).first exp_data = {:rss2_id => rss2_id, :start_date => start_date, :end_date => end_date, :organizationt_title_translations => organization_title, :job_title_translations => job_title, :member_profile => mp, :experience_type => type} - if exp.nil? + if exp.nil? || rss2_id.blank? exp = Experience.create(exp_data) puts "Saving new Exp." else @@ -796,14 +799,16 @@ module FguSyncPlugin "f_start" => "start_date", "f_end" => "end_date", "f_comp" => "organization_title", - "f_empname" => "job_title" + "f_empname" => "job_title", + "rss_id" => "rss2_id" }, 'vrul_inemp' => { "f_start" => "start_date", "f_end" => "end_date", "f_unit" => "organization_title", "f_empname" => "job_title", - "f_emptype" => "emp_type" + "f_emptype" => "emp_type", + "rss_id" => "rss2_id" }, 'dbo.v_rul_research_credential' => { "紀錄編號" => "rss2_id", @@ -936,7 +941,10 @@ module FguSyncPlugin end def self.query_db(table_name, filter_params={}) - order_fields = {} # true => order by first column with desc order + order_fields = { + 'vrul_exp' => false, + 'vrul_inemp' => false + } # true => order by first column with desc order rss_id_offsets = {} # rss_id_offsets = { # 'rsspublish' => 1073443 @@ -978,6 +986,8 @@ module FguSyncPlugin h.each do |k,v| if v.class == String h[k] = v.strip + elsif v.class == BigDecimal + h[k] = v.to_i end end tmp.each do |k,v| @@ -1033,6 +1043,8 @@ module FguSyncPlugin h.each do |k,v| if v.class == String h[k] = v.strip + elsif v.class == BigDecimal + h[k] = v.to_i end end end