Explain the "why"

This commit is contained in:
Alexander Hess 2026-12-04 10:00:39 +01:00
commit f025923d25
Signed by: alexander
GPG key ID: B46EDB4DFC26805D

View file

@ -185,13 +185,13 @@ class City(meta.Base):
) )
if order_counts: if order_counts:
# Calculate the number of orders for ALL restaurants ... # Several restaurants may share an address
# => Count the orders of all of them
n_orders = db.session.execute( n_orders = db.session.execute(
sa.select(sa.func.count(db.Order.id)) sa.select(sa.func.count(db.Order.id))
.join(db.Address, db.Order.pickup_address_id == db.Address.id) .join(db.Address, db.Order.pickup_address_id == db.Address.id)
.where(db.Address.primary_id == address.id), .where(db.Address.primary_id == address.id),
).scalar_one() ).scalar_one()
# ... and adjust the size of the red dot on the `.map`
if n_orders >= 1000: if n_orders >= 1000:
radius = 20 radius = 20
elif n_orders >= 500: elif n_orders >= 500: