Пример #1
0
    def get(request):
        """
        Pass graph data to frontend.
        """
        timeline = InstallationStatistics.timeline()

        students, courses, instances = InstallationStatistics.data_per_period()

        instances_count, courses_count, students_count = InstallationStatistics.overall_counts(
        )

        first_datetime_of_update_data, last_datetime_of_update_data = get_data_created_datetime_scope(
        )

        context = {
            'timeline': json.dumps(timeline),
            'students': json.dumps(students),
            'courses': json.dumps(courses),
            'instances': json.dumps(instances),
            'instances_count': instances_count,
            'courses_count': courses_count,
            'students_count': students_count,
            'first_datetime_of_update_data': first_datetime_of_update_data,
            'last_datetime_of_update_data': last_datetime_of_update_data
        }

        return render(request, 'charts/graphs.html', context)
Пример #2
0
    def test_overall_counts(self, mock_get_last_calendar_day):
        """
        Verify that overall_counts method returns overall statistics instance counts for previous calendar day.
        """
        mock_get_last_calendar_day.return_value = date(2017, 6, 1), date(2017, 6, 2)

        result = InstallationStatistics.overall_counts()

        self.assertEqual(
            (2, 2, 10), result
        )