Ver Fonte

sql optimization

Hal De há 2 anos atrás
pai
commit
435c486eae
1 ficheiros alterados com 2 adições e 2 exclusões
  1. 2 2
      app/app.py

+ 2 - 2
app/app.py

@@ -596,11 +596,11 @@ async def getUserCDR(user,
   if start is None:
     start=(end - td(hours=24))
   _linked_q += f''' AND calldate BETWEEN "{start}" AND "{end}" GROUP BY linkedid'''
-  if None not in (limit, offset):
+  if None not in (limit, offset): #This version of MariaDB doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
     _linked_q += f''' LIMIT {offset},{limit}'''
   start1 = (start-td(hours=4))
   end1 = (end+td(hours=4))
-  _q = f'''SELECT * FROM cdr  WHERE linkedid in ({_linked_q}) and calldate BETWEEN "{start1}" AND "{end1}";'''
+  _q = f'''SELECT * FROM cdr  WHERE linkedid in (select * from ({_linked_q}) tmp) and calldate BETWEEN "{start1}" AND "{end1}";'''
   app.logger.warning('SQL: {}'.format(_q))
   _cdr = {}
   async for row in db.iterate(query=_q):