Jul 13 - Optimize code

This commit is contained in:
2026-07-13 16:52:00 -04:00
parent 936d860342
commit 00a9ba7770
27 changed files with 141 additions and 208 deletions
+2 -1
View File
@@ -4,6 +4,7 @@ Portable across MySQL and SQLite (no spatial extension needed). For large-scale
deployments, see README for the MySQL POINT + SPATIAL INDEX upgrade.
"""
import math
from app.extensions import db
from app.models.geo import ZipGeo
EARTH_MI = 3958.7613 # mean earth radius, miles
@@ -11,7 +12,7 @@ EARTH_MI = 3958.7613 # mean earth radius, miles
def geocode_zip(zip_code):
"""Return (lat, lng, city, state, metro) or None."""
row = ZipGeo.query.get((zip_code or "").strip())
row = db.session.get(ZipGeo, (zip_code or "").strip())
if row is None:
return None
return row.lat, row.lng, row.city, row.state, row.metro