def attendance_stats(district): stats = [] location = Location.tree.root_nodes()[0] start_date, end_date = previous_calendar_week() dates = {'start':start_date, 'end':end_date} # import pdb;pdb.set_trace() boys = ["boys_%s" % g for g in GRADES] values = total_attribute_value(boys, start_date=start_date, end_date=end_date, location=location) stats.append(('boys', location_values(district, values))) girls = ["girls_%s" % g for g in GRADES] values = total_attribute_value(girls, start_date=start_date, end_date=end_date, location=location) stats.append(('girls', location_values(district, values))) total_pupils = ["boys_%s" % g for g in GRADES] + ["girls_%s" % g for g in GRADES] values = total_attribute_value(total_pupils, start_date=start_date, end_date=end_date, location=location) stats.append(('total pupils', location_values(district, values))) values = total_attribute_value("teachers_f", start_date=start_date, end_date=end_date, location=location) stats.append(('female teachers', location_values(district, values))) values = total_attribute_value("teachers_m", start_date=start_date, end_date=end_date, location=location) stats.append(('male teachers', location_values(district, values))) values = total_attribute_value(["teachers_f", "teachers_m"], start_date=start_date, end_date=end_date, location=location) stats.append(('total teachers', location_values(district, values))) res = {} res['dates'] = dates res['stats'] = stats return res
def test_should_calculate_first_day_of_previous_week_from_now(self): end_date = datetime.datetime.now().date() start_date = end_date - datetime.timedelta(days=7) returned = previous_calendar_week() returned_start_date = returned[0].date() returned_end_date = returned[1].date() self.assertEquals((returned_start_date, returned_end_date), (start_date, end_date))
def attendance_stats(district): stats = [] location = Location.tree.root_nodes()[0] start_date, end_date = previous_calendar_week() dates = {'start': start_date, 'end': end_date} # import pdb;pdb.set_trace() boys = ["boys_%s" % g for g in GRADES] values = total_attribute_value(boys, start_date=start_date, end_date=end_date, location=location) stats.append(('boys', location_values(district, values))) girls = ["girls_%s" % g for g in GRADES] values = total_attribute_value(girls, start_date=start_date, end_date=end_date, location=location) stats.append(('girls', location_values(district, values))) total_pupils = ["boys_%s" % g for g in GRADES] + ["girls_%s" % g for g in GRADES] values = total_attribute_value(total_pupils, start_date=start_date, end_date=end_date, location=location) stats.append(('total pupils', location_values(district, values))) values = total_attribute_value("teachers_f", start_date=start_date, end_date=end_date, location=location) stats.append(('female teachers', location_values(district, values))) values = total_attribute_value("teachers_m", start_date=start_date, end_date=end_date, location=location) stats.append(('male teachers', location_values(district, values))) values = total_attribute_value(["teachers_f", "teachers_m"], start_date=start_date, end_date=end_date, location=location) stats.append(('total teachers', location_values(district, values))) res = {} res['dates'] = dates res['stats'] = stats return res