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)
def test_timeline(self): """ Verify that timeline method returns unique existing datetime sorted in descending order. """ result = InstallationStatistics.timeline() self.assertEqual( ['2017-06-01', '2017-06-02', '2017-06-03', '2017-06-04', '2017-06-05'], result )