Ver código fonte

make limiting historic records optional

Daniel Sheffield 2 anos atrás
pai
commit
539e814e38
2 arquivos alterados com 8 adições e 7 exclusões
  1. 1 1
      app/db_utils.py
  2. 7 6
      app/price_view.py

+ 1 - 1
app/db_utils.py

@@ -125,7 +125,7 @@ class QueryManager(object):
         self.display = display
         self.cursor = cursor
     
-    def get_historic_prices(self, rating_cb, sort, product, unit, organic=None, limit='365 days'):
+    def get_historic_prices(self, rating_cb, sort, product, unit, organic=None, limit=None):
         statement = get_historic_prices_statement(sort, product, unit, organic=organic, limit=limit)
         #print(self.cursor.mogrify(statement).decode('utf-8'))
         #input()

+ 7 - 6
app/price_view.py

@@ -28,12 +28,13 @@ def get_where(product, unit, organic=None, limit='90 days'):
             SQL('='),
             Literal(organic),
         ]))
-    #where.append(
-    #    SQL("{ts} at time zone 'utc' BETWEEN now() - {interval} AND now()").format(
-    #        ts=Identifier('ts'),
-    #        interval=SQL("{literal}::interval").format(literal=Literal(limit))
-    #    )
-    #)
+    if limit:
+        where.append(
+            SQL("{ts} at time zone 'utc' BETWEEN now() - {interval} AND now()").format(
+                ts=Identifier('ts'),
+                interval=SQL("{literal}::interval").format(literal=Literal(limit))
+            )
+        )
     where.append(
         SQL("(SELECT id FROM units WHERE name = {unit}) = conv._to").format(
             unit=Literal(unit),