Sfoglia il codice sorgente

allow properties without size

Martin 5 anni fa
parent
commit
83e6124a94
3 ha cambiato i file con 24 aggiunte e 9 eliminazioni
  1. 4 1
      properties.py
  2. 17 7
      ranking.py
  3. 3 1
      visualize.py

+ 4 - 1
properties.py

@@ -10,9 +10,12 @@ def load_properties(require_active, require_update_since):
 
         res = {}
         for property_id, lat, lon, size, price, bedrooms, ber, bathrooms, property_type in rows:
-            if not price or not size or not lat or not lon:
+            if not price or not lat or not lon:
                 continue
 
+            if not size:
+                size = 0
+
             if not any(geo_util.inside((lat, lon), bbox) for bbox in config.MONITORED_BBOXES.values()):
                 continue
 

+ 17 - 7
ranking.py

@@ -25,18 +25,26 @@ _TYPE_CONF = {
 
 _BER_CONF = {
     25: 1, # A1
-    70: 0.7, # A3
+    70: 1, # A3
     # 100: 0.5, # B1
     # 140: 0.2, # B2
-    280: 0.6, # #D2
+    150: 0.6, # # B3
     # 300: 0.2, # E1
-    # 450: 1, # G
+    # 400: 0.4,
+    450: 0.2, # G
+    # 400: 0.4
 }
 
+# _BER_CONF = {
+#     210: 1,
+#     440: 0.6,
+# }
+
 _SIZE_CONF = {
-    100: 0.5,
+    None: 0.5,
+    80: 0.5,
     150: 1,
-    400: 1,
+    200: 1,
 }
 
 _BEDROOMS_CONF = {
@@ -63,8 +71,8 @@ _COMMUTE_CONF = {
 }
 
 _PRICE_CONF = {
-    300: 1,
-    600: 0.6,
+    400: 1,
+    900: 0.6,
 }
 
 _RERANKING_CONF = {
@@ -75,6 +83,8 @@ _RERANKING_CONF = {
 def _linear(signal, configuration):
     if signal in configuration:
         return configuration[signal]
+    if not signal and configuration.get(None):
+        return configuration[None]
     
     if signal is None:
         return 0

+ 3 - 1
visualize.py

@@ -1,3 +1,4 @@
+import sys
 import commute
 import config
 import db
@@ -128,7 +129,8 @@ def _set_tmp_ids(properties_dict):
     return res
 
 def run():
-    load_since = datetime.datetime.now() - datetime.timedelta(days=30)
+    days = int(sys.argv[1]) if len(sys.argv) > 1 else 31
+    load_since = datetime.datetime.now() - datetime.timedelta(days=days)
     properties_dict = properties.load_properties(True, load_since)
     print('Loaded %i properties' % len(properties_dict))