From 44004467184d4c6dc53a92543cfd195f91c61b99 Mon Sep 17 00:00:00 2001 From: Vivek Santayana Date: Thu, 2 Feb 2023 22:16:09 +0000 Subject: [PATCH] Bugfix: Sorting for empty dates --- ref-test/app/admin/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ref-test/app/admin/views.py b/ref-test/app/admin/views.py index ea66a53..965d216 100644 --- a/ref-test/app/admin/views.py +++ b/ref-test/app/admin/views.py @@ -34,11 +34,11 @@ def _home(): write('system.log', f'Database error when processing request \'{request.url}\': {exception}') return abort(500) current_tests = [ test for test in tests if test.end_date >= datetime.now() and test.start_date.date() <= date.today() ] - current_tests.sort(key= lambda x: x.end_date, reverse=True) + current_tests.sort(key= lambda x: x.end_date or datetime.datetime(datetime.MINYEAR,1,1), reverse=True) upcoming_tests = [ test for test in tests if test.start_date.date() > datetime.now().date()] - upcoming_tests.sort(key= lambda x: x.start_date) + upcoming_tests.sort(key= lambda x: x.start_date or datetime.datetime(datetime.MINYEAR,1,1)) recent_results = [result for result in results if not result.status == 'started' ] - recent_results.sort(key= lambda x: x.end_time, reverse=True) + recent_results.sort(key= lambda x: x.end_time or datetime.datetime(datetime.MINYEAR,1,1), reverse=True) return render_template('/admin/index.html', current_tests = current_tests, upcomimg_tests = upcoming_tests, recent_results = recent_results) @admin.route('/settings/')