Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Commit

Permalink
Solve bug in querying arrays from last_values
Browse files Browse the repository at this point in the history
  • Loading branch information
sergirubio committed Feb 23, 2018
1 parent d470883 commit a5dd5b3
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions PyTangoArchiving/hdbpp/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,8 @@ def get_attribute_values(self,table,start_date=None,stop_date=None,
query = 'select %s from %s %s order by data_time' \
% (what,table,interval)
if desc: query+=" desc" # or (not stop_date and N>0):
if N>0: query+=' limit %s'%N
if N>0:
query+=' limit %s'%(N if 'array' not in table else 1024)

######################################################################
# QUERY
Expand All @@ -605,13 +606,14 @@ def get_attribute_values(self,table,start_date=None,stop_date=None,
######################################################################

if 'array' in table:
t = result[0][0]
interval += " and CAST(UNIX_TIMESTAMP(data_time) as INT) = '%s'" \
% round(t)
query = 'select %s from %s %s order by data_time' \
% (what, table, interval)
self.warning(query)
result = self.Query(query)
#t = result[0][0]
#if 0: #N == 1:
#interval += " and CAST(UNIX_TIMESTAMP(data_time) as INT) = '%s'" \
#% round(t)
#query = 'select %s from %s %s order by data_time' \
#% (what, table, interval)
#self.warning(query)
#result = self.Query(query)
data = fandango.dicts.defaultdict(list)
for t in result:
data[float(t[0])].append(t[1:])
Expand All @@ -625,6 +627,7 @@ def get_attribute_values(self,table,start_date=None,stop_date=None,
break
l[t[0]] = t[1] #Ignoring extra columns (e.g. quality)
result.append((k,l))
if N > 0: result = result[-N:]
self.warning('array arranged [%d] in %f s'
% (len(result),time.time()-t0))
t0 = time.time()
Expand Down

0 comments on commit a5dd5b3

Please sign in to comment.