Exemple #1
0
def index():
    project="realtortest"
    stats = get_scrapyd_stat(project)
    data = datastore.list()
    [d.update({"per_sqft":float(d["price"])/float(d["sqft"])}) for d in data]
    return render_template("main.html",
            data=data,
            job_id=get_flashed_messages(),
            fields=datastore.list()[0].keys(),
            **stats)
Exemple #2
0
def aggregate_stats():
    """
    a simple, contrived example of using our (very inefficient) datastore
    to glean some insight into the data

    admittedly, there's a *lot* of very inefficient work here!
    """
    allstats = datastore.list()  ## just get it all
    p_types = set()
    for stat in allstats:
        p_types.add(stat["property_type"])
    price_sqft = {"all":[float(p["price"])/float(p["sqft"]) for p in allstats]}
    price_sqft.update({"mean":sum(price_sqft["all"])/len(price_sqft["all"]),
                        "med":price_sqft["all"][int(len(price_sqft["all"])/2)]})
    #price_bath = {"all":[float(p["price"])/float(p["baths"]) for p in allstats]}
    #price_bath.update({"mean":sum(price_bath["all"])/len(price_bath["all"]),
                        #"med":price_bath["all"][int(len(price_bath["all"])/2)]})

    return {"types":list(p_types),
            "price_sqft":price_sqft,
            #"price_bed":price_bed,
            #"price_bath":price_bath,
            }