Skip to content

Commit 6b92832

Browse files
committed
mirrors: use Django for getting the last modified mirrorlog
With SQlite this returns a string not a datetime object with PostgreSQL it does return a datetime.
1 parent 378d4b0 commit 6b92832

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

mirrors/views/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from itertools import groupby
33
from operator import attrgetter, itemgetter
44

5-
from django.db import connection
5+
from django.core.exceptions import ObjectDoesNotExist
66
from django.http import Http404
77
from django.shortcuts import get_object_or_404, render
88
from django.utils.timezone import now
@@ -104,9 +104,10 @@ def url_details(request, name, url_id):
104104

105105

106106
def status_last_modified(request, *args, **kwargs):
107-
cursor = connection.cursor()
108-
cursor.execute("SELECT MAX(check_time) FROM mirrors_mirrorlog")
109-
return cursor.fetchone()[0]
107+
try:
108+
return MirrorLog.objects.latest('check_time').check_time
109+
except ObjectDoesNotExist:
110+
return
110111

111112

112113
@condition(last_modified_func=status_last_modified)

0 commit comments

Comments
 (0)