|
|
@@ -5,8 +5,13 @@ import config
|
|
|
def load_properties(require_active, require_update_since):
|
|
|
ts = db.datetime_to_str(require_update_since)
|
|
|
with db.connect() as conn:
|
|
|
- rows = conn.select('select id, lat, lon, size, price, bedrooms, ber, bathrooms, property_type from properties '
|
|
|
- 'where price<%i and last_update > "%s"' % (config.MAX_PRICE, ts))
|
|
|
+ favourites = set(conn.select('select id from annotations where favourited=1'))
|
|
|
+ favourites_str = ','.join([str(x) for x in favourites])
|
|
|
+
|
|
|
+ rows = conn.select(
|
|
|
+ 'select id, lat, lon, size, price, bedrooms, ber, bathrooms, property_type from properties '
|
|
|
+ 'where (price<%i and last_update > "%s") or (id in (%s))' % (config.MAX_PRICE, ts, favourites_str)
|
|
|
+ )
|
|
|
|
|
|
res = {}
|
|
|
for property_id, lat, lon, size, price, bedrooms, ber, bathrooms, property_type in rows:
|
|
|
@@ -34,6 +39,7 @@ def load_properties(require_active, require_update_since):
|
|
|
'price_history': [],
|
|
|
'ber': ber,
|
|
|
'type': property_type,
|
|
|
+ 'favourite': property_id in favourites,
|
|
|
}
|
|
|
|
|
|
rows = conn.select('select time, property_id, price from search_results order by time asc')
|
|
|
@@ -41,7 +47,7 @@ def load_properties(require_active, require_update_since):
|
|
|
if pid not in res:
|
|
|
continue
|
|
|
|
|
|
- if time < ts:
|
|
|
+ if pid not in favourites and time < ts:
|
|
|
del res[pid]
|
|
|
continue
|
|
|
|