diff --git a/src/velofy/console/forecasts.py b/src/velofy/console/forecasts.py index 75864e5..3a5ca60 100644 --- a/src/velofy/console/forecasts.py +++ b/src/velofy/console/forecasts.py @@ -112,8 +112,8 @@ def tactical_heuristic( # noqa:C901,D417,DOC001 .filter(db.Grid.side_length == side_length) .filter(db.Forecast.time_step == time_step) .filter(db.Forecast.train_horizon == train_horizon) - .first() - )[0] + .scalar() + ) # ... or start `train_horizon` weeks after the first `Order` # if no `Forecast`s are in the database yet. if last_predict_at is None: diff --git a/src/velofy/console/gridify.py b/src/velofy/console/gridify.py index 5107fd4..ea72bc5 100644 --- a/src/velofy/console/gridify.py +++ b/src/velofy/console/gridify.py @@ -35,8 +35,7 @@ def gridify() -> None: # pragma: no cover note:b1f68d24 click.echo(f" -> created {len(grid.pixels)} pixels") # Because the number of assigned addresses is the same across - # different `side_length`s, we can take any `grid` from the `city`. - grid = db.session.query(db.Grid).filter_by(city=city).first() + # different `side_length`s, we can take the last `grid` from the `city`. n_assigned = ( db.session.query(db.AddressPixelAssociation) .filter(db.AddressPixelAssociation.grid_id == grid.id)