def get_last_week(): print "Fetching last week" room_id = request.form.get('room_id') datatype = int(request.form.get('datatype')) room = Room.query.get(int(room_id)) if room == None: flash('Room not found') abort(404) if g.user.role != ROLE_ADMIN: if g.user.property_id != datastream.feed.property_id: abort(401) datastreams=room.get_datastream_type(dataType=datatype) print "going to contract" value = get_last_week_values(datastreams=datastreams,property=room.property) print "back from contract" print value if datatype != 2: value = round(value/1000,2) else: value = round(value,2) value = str(value) + " " + getUnit(datatype=datatype) print value return value
def get_last_year(): room_id = request.form.get('room_id') datatype = int(request.form.get('datatype')) room = Room.query.get(int(room_id)) if room == None: flash('Room not found') abort(404) if g.user.role != ROLE_ADMIN: if g.user.property_id != datastream.feed.property_id: abort(401) datastreams=room.get_datastream_type(dataType=datatype) value = get_last_year_values(datastreams=datastreams,property=room.property) if datatype != 2: value = round(value/1000,2) else: value = round(value,2) value = str(value) + " " + getUnit(datatype=datatype) print value return value