From ebfaf2df79c59fee9cf94c8f1ec5caed5b06b3f5 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 1 Jun 2016 16:19:34 +0800 Subject: [PATCH] changed analysis year to publication date --- app/helpers/admin/journal_papers_helper.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/helpers/admin/journal_papers_helper.rb b/app/helpers/admin/journal_papers_helper.rb index 79bb607..49b3861 100644 --- a/app/helpers/admin/journal_papers_helper.rb +++ b/app/helpers/admin/journal_papers_helper.rb @@ -137,22 +137,24 @@ module Admin::JournalPapersHelper data["name"] = jl.title 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) - t = jl.journal_papers.where(:year => year, :member_profile_id.in => mps).count rescue 0 + d1 = DateTime.new(year,1,1,0,0) + 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 finaldata << data end data = {"name" => "N/A", "data" => {}} (year_start..year_end).each do |year| + d1 = DateTime.new(year,1,1,0,0) + d2 = DateTime.new(year,12,31,23,59) case type when "paper_type" - t = JournalPaper.where(:year => year, :member_profile_id.in => mps, :journal_paper_type_id => nil).count rescue 0 + t = JournalPaper.where(:publication_date.gte => d1, :publication_date.lte => d2, :member_profile_id.in => mps, :journal_paper_type_id => nil).count rescue 0 when "level_type" - t = JournalPaper.where(:year => year, :member_profile_id.in => mps, :journal_level_ids => nil).count rescue 0 + t = JournalPaper.where(:publication_date.gte => d1, :publication_date.lte => d2, :member_profile_id.in => mps, :journal_level_ids => nil).count rescue 0 when "author_type" - t = JournalPaper.where(:year => year, :member_profile_id.in => mps, :journal_paper_author_type_ids => nil).count rescue 0 + 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