def get_properties(): rs = cached_query("SELECT mls, prices, area FROM mls") properties = [] for result_row in rs: result_row["prices"] = aws.get_price_list(result_row["prices"], convert_to_float=True) result_row["current_price"] = result_row["prices"][-1] result_row["area"] = float(result_row["area"].replace(" sqft.", "")) properties.append(result_row) return properties
def needs_update(mls, price): log.info("Looking for %s for %s" % (price, mls)) rs = mls_domain.select("SELECT * FROM mls WHERE mls='%s'" % mls) for item in rs: for existing_price, timestamp in aws.get_price_list(item["prices"]): # If there is an item with the same price, this item doesn't need an update if existing_price == price: log.info("Found it") return False, item return True, None
def format_result(result): price_list = aws.get_price_list(result["prices"]) if len(price_list) > 1: prices = [str(price) for price,timestamp in price_list] price = ", ".join(prices) else: price, _ = price_list[0] last_seen = datetime.datetime(*aws.from_iso(result["last_seen"])[:6]) last_seen_str = str(datetime.datetime.now() - last_seen) return "%s - %s: %s br %s: %s (last seen %s, %s)" % (result["city"], result["region"], result["bedrooms"], result["type"], price, last_seen_str, result["mls"])