parent
d0f4107b9b
commit
8c61d0d819
@ -1,22 +1,31 @@
|
||||
module EcMajorSchoolsHelper
|
||||
def total_graduation_count year
|
||||
g_count = EcGraduationSubitem.where(:ec_graduation_requirement_id => year.ec_graduation_requirements).count
|
||||
def total_graduation_count(year)
|
||||
g_count = year.ec_graduation_subitems.count
|
||||
g_count == 0 ? "--" : g_count
|
||||
# 36
|
||||
end
|
||||
|
||||
def sigle_graduation_count
|
||||
'--'
|
||||
# 30
|
||||
def sigle_graduation_count(ec_year)
|
||||
return '--' if ec_year.ec_graduation_subitems.count.zero?
|
||||
|
||||
subitem_ids = ec_year.ec_graduation_subitems.reorder(nil).pluck(:id)
|
||||
|
||||
relations = EcGraduationRequirementCalculation.joins(ec_course_support: :ec_graduation_subitem_courses).where('ec_graduation_subitem_id in (?)', subitem_ids)
|
||||
|
||||
reached_map = relations.where(status: true).group('ec_graduation_subitem_id').count
|
||||
|
||||
reached_map.keys.size
|
||||
end
|
||||
|
||||
def total_graduation_course_count ec_year
|
||||
ec_year.ec_courses.count == 0 ? '--' : ec_year.ec_courses.count
|
||||
# 64
|
||||
ec_year.ec_courses.count.zero? ? '--' : ec_year.ec_courses.count
|
||||
end
|
||||
|
||||
def sigle_graduation_course_count
|
||||
'--'
|
||||
# 60
|
||||
def sigle_graduation_course_count(ec_year)
|
||||
return '--' if ec_year.ec_courses.count.zero?
|
||||
|
||||
course_ids = ec_year.ec_courses.map(&:id)
|
||||
target_count_map = EcCourseTarget.where(ec_course_id: course_ids).group(:ec_course_id).count
|
||||
|
||||
ec_year.ec_courses.sum { |course| course.complete_target_count == target_count_map[course.id] ? 1 : 0 }
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in new issue