From 0fdc2d554d63b540b7d85f52272d73a13bba2048 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 1 Jun 2016 16:16:08 +0800 Subject: [PATCH] changed analysis created_at to year --- app/helpers/admin/journal_papers_helper.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/helpers/admin/journal_papers_helper.rb b/app/helpers/admin/journal_papers_helper.rb index 0858313..79bb607 100644 --- a/app/helpers/admin/journal_papers_helper.rb +++ b/app/helpers/admin/journal_papers_helper.rb @@ -137,24 +137,22 @@ 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(:created_at.gte => d1, :created_at.lte => d2, :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(:year => year, :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(:created_at.gte => d1, :created_at.lte => d2, :member_profile_id.in => mps, :journal_paper_type_id => nil).count rescue 0 + t = JournalPaper.where(:year => year, :member_profile_id.in => mps, :journal_paper_type_id => nil).count rescue 0 when "level_type" - t = JournalPaper.where(:created_at.gte => d1, :created_at.lte => d2, :member_profile_id.in => mps, :journal_level_ids => nil).count rescue 0 + t = JournalPaper.where(:year => year, :member_profile_id.in => mps, :journal_level_ids => nil).count rescue 0 when "author_type" - t = JournalPaper.where(:created_at.gte => d1, :created_at.lte => d2, :member_profile_id.in => mps, :journal_paper_author_type_ids => nil).count rescue 0 + t = JournalPaper.where(:year => year, :member_profile_id.in => mps, :journal_paper_author_type_ids => nil).count rescue 0 end data["data"][year.to_s] = t