Pin the dependencies ...
... after upgrading: - alembic - matplotlib - pandas - rpy2 - sqlalchemy - statsmodels - dev dependencies + coverage + factory-boy + faker + nox + packaging + pre-commit + flake8-annotations + pytest + pytest-cov + sphinx - research dependencies + numpy + pyty - transient dependencies + astpretty + atomicwrites + bleach + chardet + colorlog + darglint + flake8-comprehensions + gitpython + identify + ipykernel + ipython + jedi + jinja2 + jupyter-client + jupyter-core + mako + nbformat + nest-asyncio + notebook + parso + pluggy + prompt-toolkit + ptyprocess + pygments + pyyaml + pyzmq + requests + smmap + terminado + textfixtures + snowballstemmer + typed-ast + urllib3 + virtualenv - fix SQL statements written in raw text
This commit is contained in:
parent
50b35a8284
commit
0da86e5f07
3 changed files with 504 additions and 481 deletions
866
poetry.lock
generated
866
poetry.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -218,6 +218,7 @@ class City(meta.Base):
|
|||
all_zip_codes = sorted(
|
||||
row[0]
|
||||
for row in db.session.execute(
|
||||
sa.text(
|
||||
f""" -- # noqa:S608
|
||||
SELECT DISTINCT
|
||||
zip_code
|
||||
|
@ -226,6 +227,7 @@ class City(meta.Base):
|
|||
WHERE
|
||||
city_id = {self.id};
|
||||
""",
|
||||
),
|
||||
)
|
||||
)
|
||||
cmap = utils.make_random_cmap(len(all_zip_codes), bright=False)
|
||||
|
|
|
@ -6,6 +6,7 @@ import datetime as dt
|
|||
from typing import Tuple
|
||||
|
||||
import pandas as pd
|
||||
import sqlalchemy as sa
|
||||
|
||||
from urban_meal_delivery import config
|
||||
from urban_meal_delivery import db
|
||||
|
@ -68,7 +69,8 @@ class OrderHistory:
|
|||
# `data` is probably missing "pixel_id"-"start_at" pairs.
|
||||
# This happens when there is no demand in the `Pixel` in the given `time_step`.
|
||||
data = pd.read_sql_query(
|
||||
f"""-- # noqa:E501,WPS221
|
||||
sa.text(
|
||||
f""" -- # noqa:WPS221
|
||||
SELECT
|
||||
pixel_id,
|
||||
start_at,
|
||||
|
@ -80,9 +82,11 @@ class OrderHistory:
|
|||
FROM (
|
||||
SELECT
|
||||
pixels.pixel_id,
|
||||
DATE_TRUNC('MINUTE', orders.placed_at) AS placed_at_without_seconds,
|
||||
DATE_TRUNC('MINUTE', orders.placed_at)
|
||||
AS placed_at_without_seconds,
|
||||
((
|
||||
EXTRACT(MINUTES FROM orders.placed_at)::INTEGER % {self._time_step}
|
||||
EXTRACT(MINUTES FROM orders.placed_at)::INTEGER
|
||||
% {self._time_step}
|
||||
)::TEXT || ' MINUTES')::INTERVAL
|
||||
AS minutes_to_be_cut
|
||||
FROM (
|
||||
|
@ -114,7 +118,7 @@ class OrderHistory:
|
|||
WHERE
|
||||
grid_id = {self._grid.id}
|
||||
AND
|
||||
city_id = {self._grid.city.id} -- redundant -> sanity check
|
||||
city_id = {self._grid.city.id} -- -> sanity check
|
||||
) AS pixels
|
||||
ON orders.pickup_address_id = pixels.address_id
|
||||
) AS placed_at_aggregated_into_start_at
|
||||
|
@ -126,6 +130,7 @@ class OrderHistory:
|
|||
pixel_id,
|
||||
start_at;
|
||||
""",
|
||||
), # noqa:WPS355
|
||||
con=db.connection,
|
||||
index_col=['pixel_id', 'start_at'],
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue