| 123456789101112131415161718192021222324252627 |
- import db
- import geo_util
- import config
- import ranking
- def load_properties():
- with db.connect() as conn:
- rows = conn.select('select id, lat, lon, size, price, bedrooms from properties where price<450000')
- res = {}
- for property_id, lat, lon, size, price, bedrooms in rows:
- if not price or not size or not lat or not lon:
- continue
- if not any(geo_util.inside((lat, lon), bbox) for bbox in config.MONITORED_BBOXES):
- continue
- price = price/1000
- res[property_id] = {
- 'loc': (lat, lon),
- 'size': size,
- 'price': price,
- 'bedrooms': bedrooms,
- }
- return res
|