|
@@ -61,30 +61,13 @@ def get_historic_prices_statement(sort, product, unit, organic=None, limit='90 d
|
|
|
)""")
|
|
|
select = OrderedDict([
|
|
|
('id', Identifier('transactions','id')),
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
('%d/%m/%y %_I%P', SQL("""(transactions.ts AT TIME ZONE 'UTC')::timestamp without time zone""")),
|
|
|
-
|
|
|
('code', Identifier('stores', 'code')),
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
('$/unit', SQL("""TRUNC(price / (quantity * factor), 4)""")),
|
|
|
('avg', SQL(f"""TRUNC(sum(price) OVER {partition} / sum(quantity * factor) OVER {partition}, 4)""")),
|
|
|
('min', SQL(f"""TRUNC(min(price / (quantity * factor)) OVER {partition}, 4)""")),
|
|
|
('max', SQL(f"""TRUNC(max(price / (quantity * factor)) OVER {partition}, 4)""")),
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
('organic', Identifier('organic')),
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
])
|
|
|
statement = SQL('\n').join([
|
|
|
_with,
|
|
@@ -142,35 +125,3 @@ def get_historic_prices_statement(sort, product, unit, organic=None, limit='90 d
|
|
|
),
|
|
|
])
|
|
|
return statement
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|