summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoey Hagedorn <hagedorn@mcs.anl.gov>2006-08-02 23:21:47 +0000
committerJoey Hagedorn <hagedorn@mcs.anl.gov>2006-08-02 23:21:47 +0000
commitb2accde9b00493d6fc6d8c77d744f2b16087fdfa (patch)
tree1ad66edc622f8f6fe97947fe68c38539fc3acf8e
parent556d5e682665660adeffda3a8894e756ccbcb967 (diff)
downloadbcfg2-b2accde9b00493d6fc6d8c77d744f2b16087fdfa.tar.gz
bcfg2-b2accde9b00493d6fc6d8c77d744f2b16087fdfa.tar.bz2
bcfg2-b2accde9b00493d6fc6d8c77d744f2b16087fdfa.zip
NewReports: Fixes database portability problem with typecasting dates; for all Displays
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2032 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r--reports/brpt/reports/models.py1
-rw-r--r--reports/brpt/reports/views.py18
2 files changed, 15 insertions, 4 deletions
diff --git a/reports/brpt/reports/models.py b/reports/brpt/reports/models.py
index c1818fd66..3a786a796 100644
--- a/reports/brpt/reports/models.py
+++ b/reports/brpt/reports/models.py
@@ -88,7 +88,6 @@ class Interaction(models.Model):
state = models.CharField(maxlength=32)#good/bad/modified/etc
repo_revision = models.IntegerField()#repo revision at time of interaction
client_version = models.CharField(maxlength=32)#Client Version
- pingable = models.BooleanField()#This needs to change
goodcount = models.IntegerField()#of good config-items
totalcount = models.IntegerField()#of total config-items
diff --git a/reports/brpt/reports/views.py b/reports/brpt/reports/views.py
index 1c2d09e70..011844a18 100644
--- a/reports/brpt/reports/views.py
+++ b/reports/brpt/reports/views.py
@@ -6,7 +6,10 @@ from django.shortcuts import render_to_response, get_object_or_404
from brpt.reports.models import Client, Interaction, Bad, Modified, Extra, Performance, Reason
from datetime import datetime, timedelta
from time import strptime
-from django.db import connection
+from django.db import connection
+from django.db.backends import util
+
+
def index(request):
return render_to_response('index.html')
@@ -211,13 +214,22 @@ def prepare_client_lists(request, timestamp = 'now'):
if (timestamp == 'now' or timestamp == None):
cursor.execute("select client_id, MAX(timestamp) as timestamp from reports_interaction GROUP BY client_id")
- stale_all_client_list = Client.objects.filter(id__in=[x[0] for x in cursor.fetchall() if datetime.now() - x[1]>timedelta(days=1)])
+ results = cursor.fetchall()
+ for x in results:
+ if type(x[1]) == type(""):
+ x[1] = util.typecast_timestamp(x[1])
+
+ stale_all_client_list = Client.objects.filter(id__in=[x[0] for x in results if datetime.now() - x[1] > timedelta(days=1)])
else:
cursor.execute("select client_id, timestamp, MAX(timestamp) as timestamp from reports_interaction "+
"WHERE timestamp < %s GROUP BY client_id", [timestamp])
t = strptime(timestamp,"%Y-%m-%d %H:%M:%S")
datetimestamp = datetime(t[0], t[1], t[2], t[3], t[4], t[5])
- stale_all_client_list = Client.objects.filter(id__in=[x[0] for x in cursor.fetchall() if datetimestamp - x[1] > timedelta(days=1)])
+ results = cursor.fetchall()
+ for x in results:
+ if type(x[1]) == type(""):
+ x[1] = util.typecast_timestamp(x[1])
+ stale_all_client_list = Client.objects.filter(id__in=[x[0] for x in results if datetimestamp - x[1] > timedelta(days=1)])
[stale_up_client_list.append(x) for x in stale_all_client_list if not client_ping_dict[x.id]=='N']