Adjust settings to be consistent to avoid hidden content being overwritten.
This commit is contained in:
parent
0bbcf1e380
commit
9a7704ec6f
|
|
@ -14,6 +14,7 @@ const dbConfig = {
|
|||
connectString: process.env.ORACLE_CONNECT || '140.130.3.188:1521/dbnfua'
|
||||
};
|
||||
oracledb.fetchAsString = [ oracledb.DATE ];
|
||||
|
||||
// 通用查詢函式
|
||||
async function executeQuery(sql) {
|
||||
let connection;
|
||||
|
|
|
|||
|
|
@ -410,10 +410,7 @@ module NfuSyncPlugin
|
|||
end
|
||||
|
||||
query_result["books"].to_a.each do |book|
|
||||
bk = Book.where(:rss2_id => book["ukey"]).first
|
||||
bk.delete if bk
|
||||
|
||||
bk = Book.new
|
||||
bk = Book.where(:rss2_id => book["ukey"]).first || Book.new
|
||||
bk.rss2_id = book["ukey"]
|
||||
bk.book_title_translations = localize_data(book["book_title"])
|
||||
bk.publisher_translations = localize_data(book["publisher"])
|
||||
|
|
@ -476,10 +473,7 @@ module NfuSyncPlugin
|
|||
end
|
||||
|
||||
query_result["project"].to_a.each do |pj|
|
||||
pj_obj = Project.where(:rss2_id => pj["ukey"]).first
|
||||
pj_obj.delete if pj_obj
|
||||
|
||||
pj_obj = Project.new
|
||||
pj_obj = Project.where(:rss2_id => pj["ukey"]).first || Project.new
|
||||
pj_obj.rss2_id = pj["ukey"]
|
||||
pj_obj.project_title_translations = localize_data(pj["project_title"])
|
||||
pj_obj.job_title_translations = localize_data(pj["job_title"])
|
||||
|
|
@ -508,10 +502,7 @@ module NfuSyncPlugin
|
|||
end
|
||||
|
||||
query_result["patent"].to_a.each do |pt|
|
||||
patent = Patent.where(:rss2_id => pt["ukey"]).first
|
||||
patent.delete if patent
|
||||
|
||||
patent = Patent.new
|
||||
patent = Patent.where(:rss2_id => pt["ukey"]).first || Patent.new
|
||||
patent.rss2_id = pt["ukey"]
|
||||
patent.patent_title_translations = localize_data(pt["patent_title"])
|
||||
patent.patent_country_translations = localize_data(pt["patent_country"])
|
||||
|
|
@ -542,14 +533,8 @@ module NfuSyncPlugin
|
|||
end
|
||||
|
||||
query_result["award"].to_a.each do |hn|
|
||||
old_uid = Honor.where(:rss2_id => hn["ukey"]).first&.uid
|
||||
|
||||
honor = Honor.where(:rss2_id => hn["ukey"]).first
|
||||
honor.delete if honor
|
||||
|
||||
honor = Honor.new
|
||||
honor = Honor.where(:rss2_id => hn["ukey"]).first || Honor.new
|
||||
honor.rss2_id = hn["ukey"]
|
||||
honor.uid = old_uid
|
||||
honor.award_name_translations = localize_data(hn["award_name"])
|
||||
honor.awarding_unit_translations = localize_data(hn["award_unit"].to_s.strip)
|
||||
honor.note = hn["join_teacher"]
|
||||
|
|
@ -577,14 +562,8 @@ module NfuSyncPlugin
|
|||
end
|
||||
|
||||
query_result["course"].to_a.each do |cs|
|
||||
old_uid = Course.where(:rss2_id => cs["ukey"]).first&.uid
|
||||
|
||||
course = Course.where(:rss2_id => cs["ukey"]).first
|
||||
course.delete if course
|
||||
|
||||
course = Course.new
|
||||
course = Course.where(:rss2_id => cs["ukey"]).first || Course.new
|
||||
course.rss2_id = cs["ukey"]
|
||||
course.uid = old_uid
|
||||
course.title_translations = localize_data(cs["course_name"])
|
||||
course.course_class_translations = localize_data(cs["course_class"])
|
||||
course.url = cs["url"]
|
||||
|
|
@ -604,10 +583,7 @@ module NfuSyncPlugin
|
|||
end
|
||||
|
||||
query_result["education"].to_a.each do |edu|
|
||||
diploma = Diploma.where(:rss2_id => edu["ukey"]).first
|
||||
diploma.delete if diploma
|
||||
|
||||
diploma = Diploma.new
|
||||
diploma = Diploma.where(:rss2_id => edu["ukey"]).first || Diploma.new
|
||||
diploma.rss2_id = edu["ukey"]
|
||||
diploma.school_name_translations = localize_data(edu["school_name"])
|
||||
diploma.department_translations = localize_data(edu["department"])
|
||||
|
|
@ -628,14 +604,8 @@ module NfuSyncPlugin
|
|||
end
|
||||
|
||||
query_result["certification"].to_a.each do |cert|
|
||||
old_uid = Certificate.where(:rss2_id => cert["ukey"]).first&.uid
|
||||
|
||||
certificate = Certificate.where(:rss2_id => cert["ukey"]).first
|
||||
certificate.delete if certificate
|
||||
|
||||
certificate = Certificate.new
|
||||
certificate = Certificate.where(:rss2_id => cert["ukey"]).first || Certificate.new
|
||||
certificate.rss2_id = cert["ukey"]
|
||||
certificate.uid = old_uid
|
||||
certificate.title_translations = localize_data(cert["title"])
|
||||
certificate.issued_by = cert["issued_by"]
|
||||
certificate.acquired_date = DateTime.parse(cert["acquired_date"]).to_date if cert["acquired_date"].present?
|
||||
|
|
@ -655,14 +625,8 @@ module NfuSyncPlugin
|
|||
end
|
||||
|
||||
query_result["award_contest"].to_a.each do |ac|
|
||||
old_uid = Competition.where(:rss2_id => ac["ukey"]).first&.uid
|
||||
|
||||
competition = Competition.where(:rss2_id => ac["ukey"]).first
|
||||
competition.delete if competition
|
||||
|
||||
competition = Competition.new
|
||||
competition = Competition.where(:rss2_id => ac["ukey"]).first || Competition.new
|
||||
competition.rss2_id = ac["ukey"]
|
||||
competition.uid = old_uid
|
||||
competition.competition_name_translations = localize_data(ac["competition_name"])
|
||||
competition.work_name_translations = localize_data(ac["work_name"])
|
||||
competition.student_name_translations = localize_data(ac["student_name"])
|
||||
|
|
@ -688,14 +652,8 @@ module NfuSyncPlugin
|
|||
end
|
||||
|
||||
query_result["activity"].to_a.each do |act|
|
||||
old_uid = Activity.where(:rss2_id => act["ukey"]).first&.uid
|
||||
|
||||
activity = Activity.where(:rss2_id => act["ukey"]).first
|
||||
activity.delete if activity
|
||||
|
||||
activity = Activity.new
|
||||
activity = Activity.where(:rss2_id => act["ukey"]).first || Activity.new
|
||||
activity.rss2_id = act["ukey"]
|
||||
activity.uid = old_uid
|
||||
activity.activity_name_translations = localize_data(act["activity_name"])
|
||||
activity.activity_organizer_translations = localize_data(act["activity_organizer"].to_s.strip)
|
||||
activity.participation_status_translations = localize_data(act["participation_status"].to_s.strip)
|
||||
|
|
@ -730,14 +688,8 @@ module NfuSyncPlugin
|
|||
end
|
||||
|
||||
def sync_single_technology_transfer(tech, member)
|
||||
old_uid = TechnologyTransfer.where(:rss2_id => tech["ukey"]).first&.uid
|
||||
|
||||
tt = TechnologyTransfer.where(:rss2_id => tech["ukey"]).first
|
||||
tt.delete if tt
|
||||
|
||||
tt = TechnologyTransfer.new
|
||||
tt = TechnologyTransfer.where(:rss2_id => tech["ukey"]).first || TechnologyTransfer.new
|
||||
tt.rss2_id = tech["ukey"]
|
||||
tt.uid = old_uid
|
||||
tt.title_translations = localize_data(tech["patent_title"].to_s.strip.presence || " ")
|
||||
tt.manufacturer_name_translations = localize_data(tech["manufacturer_name"])
|
||||
tt.participating_teachers = tech["participating_teachers"]
|
||||
|
|
@ -764,14 +716,8 @@ module NfuSyncPlugin
|
|||
end
|
||||
|
||||
query_result["pro_service"].to_a.each do |vs|
|
||||
old_uid = VolunteerService.where(:rss2_id => vs["ukey"]).first&.uid
|
||||
|
||||
service = VolunteerService.where(:rss2_id => vs["ukey"]).first
|
||||
service.delete if service
|
||||
|
||||
service = VolunteerService.new
|
||||
service = VolunteerService.where(:rss2_id => vs["ukey"]).first || VolunteerService.new
|
||||
service.rss2_id = vs["ukey"]
|
||||
service.uid = old_uid
|
||||
service.volunteer_name_translations = localize_data(vs["volunteer_name"].to_s.strip.presence || " ")
|
||||
service.volunteer_organizer_translations = localize_data(vs["volunteer_organizer"])
|
||||
service.volunteer_type_translations = localize_data(vs["volunteer_type"])
|
||||
|
|
@ -794,14 +740,8 @@ module NfuSyncPlugin
|
|||
end
|
||||
|
||||
query_result["experience"].to_a.each do |exp|
|
||||
old_uid = Experience.where(:rss2_id => exp["ukey"]).first&.uid
|
||||
|
||||
experience = Experience.where(:rss2_id => exp["ukey"]).first
|
||||
experience.delete if experience
|
||||
|
||||
experience = Experience.new
|
||||
experience = Experience.where(:rss2_id => exp["ukey"]).first || Experience.new
|
||||
experience.rss2_id = exp["ukey"]
|
||||
experience.uid = old_uid
|
||||
experience.organizationt_title_translations = localize_data(exp["exp_unit"])
|
||||
experience.department_translations = localize_data(exp["exp_dept"])
|
||||
experience.job_title_translations = localize_data(exp["exp_gnam_name"])
|
||||
|
|
@ -850,14 +790,8 @@ module NfuSyncPlugin
|
|||
end
|
||||
|
||||
query_result["dissertation"].to_a.each do |dis|
|
||||
old_uid = ThesisGuidancePaper.where(:rss2_id => dis["ukey"]).first&.uid
|
||||
|
||||
paper = ThesisGuidancePaper.where(:rss2_id => dis["ukey"]).first
|
||||
paper.delete if paper
|
||||
|
||||
paper = ThesisGuidancePaper.new
|
||||
paper = ThesisGuidancePaper.where(:rss2_id => dis["ukey"]).first || ThesisGuidancePaper.new
|
||||
paper.rss2_id = dis["ukey"]
|
||||
paper.uid = old_uid
|
||||
paper.paper_title_translations = { zh_tw: dis["paper_title_zh"], en: dis["paper_title_en"] }
|
||||
paper.supervising_teacher_translations = { zh_tw: dis["supervising_teacher"], en: dis["supervising_teacher"] }
|
||||
paper.degree_translations = { zh_tw: dis["degree"], en: dis["degree"] }
|
||||
|
|
|
|||
Loading…
Reference in New Issue