def record_group_stats(): stats_utils.periodic_task('group__record_group_stats') points = [] for group in Group.objects.all(): points.extend(get_group_members_stats(group)) points.extend(get_group_places_stats(group)) points.extend(get_application_stats(group)) points.extend(get_issue_stats(group)) write_points(points)
def record_group_stats(): with timer() as t: points = [] for group in Group.objects.all(): points.extend(get_group_members_stats(group)) points.extend(get_group_places_stats(group)) points.extend(get_application_stats(group)) points.extend(get_issue_stats(group)) write_points(points) stats_utils.periodic_task('group__record_group_stats', seconds=t.elapsed_seconds)
def test_group_places_stats(self): group = GroupFactory() [PlaceFactory(group=group, status='active') for _ in range(3)] [PlaceFactory(group=group, status='negotiating') for _ in range(7)] [PlaceFactory(group=group, status='archived') for _ in range(10)] points = stats.get_group_places_stats(group) self.assertEqual(points, [{ 'measurement': 'karrot.group.places', 'tags': { 'group': str(group.id), 'group_status': 'active', }, 'fields': { 'count_total': 20, 'count_status_active': 3, 'count_status_negotiating': 7, 'count_status_archived': 10, }, }])