Sfoglia il codice sorgente

only load properties updated in the past 6 months

Martin 6 anni fa
parent
commit
efdb6c72ce
1 ha cambiato i file con 4 aggiunte e 1 eliminazioni
  1. 4 1
      properties.py

+ 4 - 1
properties.py

@@ -1,10 +1,13 @@
+import datetime
 import db
 import geo_util
 import config
 
 def load_properties(require_active=True):
+    ts = db.datetime_to_str(datetime.datetime.now() - datetime.timedelta(days=180))
     with db.connect() as conn:
-        rows = conn.select('select id, lat, lon, size, price, bedrooms, ber from properties where price<%i and property_type != "Site"' % config.MAX_PRICE)
+        rows = conn.select('select id, lat, lon, size, price, bedrooms, ber from properties '
+                           'where price<%i and property_type != "Site" and last_update > "%s"' % (config.MAX_PRICE, ts))
 
         res = {}
         for property_id, lat, lon, size, price, bedrooms, ber in rows: