diff --git a/app/controllers/member_counselors_controller.rb b/app/controllers/member_counselors_controller.rb index c15588b..bac5a11 100644 --- a/app/controllers/member_counselors_controller.rb +++ b/app/controllers/member_counselors_controller.rb @@ -7,8 +7,9 @@ class MemberCounselorsController < CUserController params = OrbitHelper.params pcity = nil page = Page.where(:page_id => params[:page_id]).first + schoolmembers = HpsMember.where(:user_type => 0).pluck(:id) cities = HpsCity.all.collect do |city| - total = city.hps_files.count + total = city.hps_files.where(:hps_member_id.in => schoolmembers).count pcity = city if idx == 0 idx = idx + 1 { @@ -22,15 +23,15 @@ class MemberCounselorsController < CUserController end total = 0 schools = pcity.hps_schools.collect do |school| - members = HpsMember.where(:hps_school_id => school.id.to_s).pluck(:id) - count = HpsFile.where(:hps_member_id.in => members).count - total = count + total - { - "name" => school.name, - "url_to_show" => OrbitHelper.url_to_show(school.to_param) + "?method=proposals", - "count" => count - } - end + members = HpsMember.where(:hps_school_id => school.id.to_s).pluck(:id) + count = HpsFile.where(:hps_member_id.in => members).count + total = count + total + { + "name" => school.name, + "url_to_show" => OrbitHelper.url_to_show(school.to_param) + "?method=proposals", + "count" => count + } + end { "cities" => cities, "schools" => schools, @@ -43,7 +44,17 @@ class MemberCounselorsController < CUserController school = HpsSchool.where(:uid => params[:uid]).first members = HpsMember.where(:hps_school_id => school.id.to_s) page = Page.where(:page_id => params[:page_id]).first + schoolmembers = HpsMember.where(:user_type => 0).pluck(:id) + files = [] + cities = HpsCity.all.collect do |city| + total = city.hps_files.where(:hps_member_id.in => schoolmembers).count + { + "name" => city.name, + "total" => total, + "url" => "/" + I18n.locale.to_s + page.url + "?city_id=#{city.id.to_s}" + } + end members.each do |member| member.hps_files.desc(:created_at).each do |file| files << { @@ -56,6 +67,7 @@ class MemberCounselorsController < CUserController end { "files" => files, + "cities" => cities, "data" => { "back-url" => "/" + I18n.locale.to_s + page.url } diff --git a/app/models/hps_member.rb b/app/models/hps_member.rb index d004cc3..4b2f8f1 100644 --- a/app/models/hps_member.rb +++ b/app/models/hps_member.rb @@ -43,11 +43,11 @@ class HpsMember def get_user_type case self.user_type when 0 - I18n.t("member_counselor.type1") + I18n.t("member_counselor.type1") #school when 1 - I18n.t("member_counselor.type2") + I18n.t("member_counselor.type2") #govt when 2 - I18n.t("member_counselor.type3") + I18n.t("member_counselor.type3") #counselor end end end \ No newline at end of file