From 6028fc0ee909c781633cef620d475ffedb482aca Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Thu, 12 Nov 2009 18:01:50 +0000 Subject: Reports: Fix traceback in Summary/System views (ticket #793 Reported by Thorsten Lockert) This commit actually fixes two issues: * Check for unicode strings * We were trying to modify an immutable tuple Signed-off-by: Sol Jerome git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5577 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Reports/reports/views.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/lib/Server/Reports') diff --git a/src/lib/Server/Reports/reports/views.py b/src/lib/Server/Reports/reports/views.py index 03a97e523..b9fa371ef 100644 --- a/src/lib/Server/Reports/reports/views.py +++ b/src/lib/Server/Reports/reports/views.py @@ -303,9 +303,11 @@ def prepare_client_lists(request, timestamp = 'now'): cursor.execute("select client_id, MAX(timestamp) as timestamp from reports_interaction GROUP BY client_id") 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.active(timestamp).filter(id__in=[x[0] for x in results if datetime.now() - x[1] > timedelta(days=1)]) + if type(x[1]) == type("") or type(x[1]) == type(u""): + ts = util.typecast_timestamp(x[1]) + else: + ts = x[1] + stale_all_client_list = Client.objects.active(timestamp).filter(id__in=[x[0] for x in results if datetime.now() - ts > 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]) -- cgit v1.2.3-1-g7c22