From 7c36fc514d5d54437e884f7b32845a6273a9e81d Mon Sep 17 00:00:00 2001 From: Eric Tsai Date: Mon, 20 Jan 2020 10:22:42 +0800 Subject: [PATCH 1/3] add form_to_start & form_to_end to import method --- app/helpers/admin/journal_papers_helper.rb | 35 ++++++++++++---------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/app/helpers/admin/journal_papers_helper.rb b/app/helpers/admin/journal_papers_helper.rb index b9bd3bd..2f8e71a 100644 --- a/app/helpers/admin/journal_papers_helper.rb +++ b/app/helpers/admin/journal_papers_helper.rb @@ -101,38 +101,43 @@ module Admin::JournalPapersHelper jp.vol_no = val when 11 jp.issue_no = val - when 12 + when 12 + jp.form_to_start = val + when 13 + jp.form_to_end = val +# index need to +2 + when 14 jp.total_pages = val - when 13 + when 15 jls = JournalLevel.asc(:created_at).all.to_a ts = val.to_s.split(",") ts.each do |t| jp.journal_level_ids << jls[t.to_i].id if t.to_s.is_i? && t.to_i < jls.count end - when 14 + when 16 jpts = JournalPaperType.asc(:created_at).all.to_a jp.journal_paper_type = jpts[val.to_i] if val.to_s.is_i? && val.to_i < jpts.count - when 15 + when 17 jpas = JournalPaperAuthorType.asc(:created_at).all.to_a ts = val.to_s.split(",") ts.each do |t| jp.journal_paper_author_type_ids << jpas[t.to_i].id if t.to_s.is_i? && t.to_i < jpas.count end - when 16 - jp.number_of_authors = val - when 17 - jp.isbn = val when 18 - jp.publication_date = val + jp.number_of_authors = val when 19 - jp.url = val - when 20 - jp.keywords = val + jp.isbn = val + when 20 + jp.publication_date = val when 21 - jp.abstract = val - when 22 - jp.note = val + jp.url = val + when 22 + jp.keywords = val when 23 + jp.abstract = val + when 24 + jp.note = val + when 25 jp.associated_project_translations = {"en" => val, "zh_tw" => val} end end From db8b0311a6ae3af2b145a458ddb09ecdb6970416 Mon Sep 17 00:00:00 2001 From: Eric Tsai Date: Mon, 20 Jan 2020 10:25:26 +0800 Subject: [PATCH 2/3] remove trailing space --- app/helpers/admin/journal_papers_helper.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/helpers/admin/journal_papers_helper.rb b/app/helpers/admin/journal_papers_helper.rb index 2f8e71a..5a083bd 100644 --- a/app/helpers/admin/journal_papers_helper.rb +++ b/app/helpers/admin/journal_papers_helper.rb @@ -70,8 +70,8 @@ module Admin::JournalPapersHelper value = {"en" => val} when 3 begin - value["zh_tw"] = val - rescue + value["zh_tw"] = val + rescue value = {"zh_tw" => val} end jp.paper_title_translations = value @@ -80,7 +80,7 @@ module Admin::JournalPapersHelper when 5 begin value["zh_tw"] = val - rescue + rescue value = {"zh_tw" => val} end jp.journal_title_translations = value @@ -89,7 +89,7 @@ module Admin::JournalPapersHelper when 7 begin value["zh_tw"] = val - rescue + rescue value = {"zh_tw" => val} end jp.authors_translations = value @@ -99,7 +99,7 @@ module Admin::JournalPapersHelper jp.language = val when 10 jp.vol_no = val - when 11 + when 11 jp.issue_no = val when 12 jp.form_to_start = val @@ -111,7 +111,7 @@ module Admin::JournalPapersHelper when 15 jls = JournalLevel.asc(:created_at).all.to_a ts = val.to_s.split(",") - ts.each do |t| + ts.each do |t| jp.journal_level_ids << jls[t.to_i].id if t.to_s.is_i? && t.to_i < jls.count end when 16 @@ -131,7 +131,7 @@ module Admin::JournalPapersHelper jp.publication_date = val when 21 jp.url = val - when 22 + when 22 jp.keywords = val when 23 jp.abstract = val @@ -153,7 +153,7 @@ module Admin::JournalPapersHelper d["name"] = role.title mps = role.member_profile_ids d1 = DateTime.new(year_start,1,1,0,0) - d2 = DateTime.new(year_end,12,31,23,59) + d2 = DateTime.new(year_end,12,31,23,59) d["data"] = JournalPaper.where(:publication_date.gte => d1, :publication_date.lte => d2, :member_profile_id.in => mps) rescue [] data << d end @@ -182,7 +182,7 @@ module Admin::JournalPapersHelper data["data"] = {} (year_start..year_end).each do |year| d1 = DateTime.new(year,1,1,0,0) - d2 = DateTime.new(year,12,31,23,59) + d2 = DateTime.new(year,12,31,23,59) t = jl.journal_papers.where(:publication_date.gte => d1, :publication_date.lte => d2, :member_profile_id.in => mps).count rescue 0 data["data"][year.to_s] = t end @@ -200,7 +200,7 @@ module Admin::JournalPapersHelper when "author_type" t = JournalPaper.where(:publication_date.gte => d1, :publication_date.lte => d2, :member_profile_id.in => mps, :journal_paper_author_type_ids => nil).count rescue 0 end - + data["data"][year.to_s] = t end finaldata << data From 605c0374c588a6812c8d461e3fd74e96a0371112 Mon Sep 17 00:00:00 2001 From: Eric Tsai Date: Mon, 20 Jan 2020 15:50:55 +0800 Subject: [PATCH 3/3] remove notice --- app/helpers/admin/journal_papers_helper.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/helpers/admin/journal_papers_helper.rb b/app/helpers/admin/journal_papers_helper.rb index 5a083bd..b447238 100644 --- a/app/helpers/admin/journal_papers_helper.rb +++ b/app/helpers/admin/journal_papers_helper.rb @@ -105,7 +105,6 @@ module Admin::JournalPapersHelper jp.form_to_start = val when 13 jp.form_to_end = val -# index need to +2 when 14 jp.total_pages = val when 15