changed analysis created_at to year

This commit is contained in:
Harry Bomrah 2016-06-01 16:16:08 +08:00
parent 4bb1e2ac02
commit 0fdc2d554d
1 changed files with 6 additions and 8 deletions

View File

@ -137,24 +137,22 @@ module Admin::JournalPapersHelper
data["name"] = jl.title data["name"] = jl.title
data["data"] = {} data["data"] = {}
(year_start..year_end).each do |year| (year_start..year_end).each do |year|
d1 = DateTime.new(year,1,1,0,0) # 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(:created_at.gte => d1, :created_at.lte => d2, :member_profile_id.in => mps).count rescue 0 t = jl.journal_papers.where(:year => year, :member_profile_id.in => mps).count rescue 0
data["data"][year.to_s] = t data["data"][year.to_s] = t
end end
finaldata << data finaldata << data
end end
data = {"name" => "N/A", "data" => {}} data = {"name" => "N/A", "data" => {}}
(year_start..year_end).each do |year| (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 case type
when "paper_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" 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" 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 end
data["data"][year.to_s] = t data["data"][year.to_s] = t