forked from saurabh/personal-research
fix export excel bug caused by related to more than one members and year in mongo's data-type is string not Fixnum.
This commit is contained in:
parent
c2bba77a78
commit
6def60f8dd
|
@ -88,7 +88,7 @@ module Admin::PersonalResearchesHelper
|
|||
mps = role.member_profile_ids
|
||||
# d1 = DateTime.new(year_start,1,1,0,0)
|
||||
# d2 = DateTime.new(year_end,12,31,23,59)
|
||||
d["data"] = Research.where(:year.gte => year_start, :year.lte => year_end, :member_profile_id.in => mps) rescue []
|
||||
d["data"] = Research.where(:year.gte => year_start.to_s, :year.lte => year_end.to_s, :member_profile_id.in => mps) rescue []
|
||||
data << d
|
||||
end
|
||||
return data
|
||||
|
@ -124,7 +124,7 @@ module Admin::PersonalResearchesHelper
|
|||
# d2 = DateTime.new(year,12,31,23,59)
|
||||
case type
|
||||
when "category"
|
||||
t = Research.where(:year => year, :member_profile_id.in => mps, :project_type_id => nil).count rescue 0
|
||||
t = Research.where(:year => year.to_s, :member_profile_id.in => mps, :project_type_id => nil).count rescue 0
|
||||
end
|
||||
|
||||
data["data"][year.to_s] = t
|
||||
|
|
|
@ -39,7 +39,7 @@ wb = xlsx_package.workbook
|
|||
sheet.add_row row, :style => heading
|
||||
|
||||
data.each do |proj|
|
||||
row = [proj.member_profile.name]
|
||||
row = [(proj.member_profile_id.class == Array ? proj.member_profile_id.map{|member_id| MemberProfile.find(member_id).name rescue ""} : [proj.member_profile.name])]
|
||||
@site_in_use_locales.each do |locale|
|
||||
row << proj.research_title_translations[locale.to_s]
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue