def dynamic_graph_data(request, input_data): ''' A view returning the JSON data used to populate the dynamic graph. ''' # Set the maximum possible start time to two hours ago # to prevent excessive drawing of data max_time = datetime.datetime.now() -DYNAMIC_START_TIME start = max( datetime.datetime.utcfromtimestamp(int(int(input_data)/1000)) , max_time ) # Grab the xy pairs data_dump = data._make_data_dump( calendar.timegm(start.timetuple()) , None, 'second*10') if not data_dump['no_results']: # Create the URL to refresh for more data junk = data._gen_now() data_url = reverse('energyweb.graph.views.dynamic_graph_data', \ kwargs={'input_data': \ str(data_dump['last_record'])}) + \ '?junk=' + junk data_dump['data_url'] = data_url json_serializer = serializers.get_serializer("json")() return HttpResponse(simplejson.dumps(data_dump), mimetype='application/json')
def data_access_data(request, start, end, res): ''' A view returning the JSON data used to populate the static graph. ''' data_dump = data._make_data_dump(start, end, res) json_serializer = serializers.get_serializer("json")() return HttpResponse(simplejson.dumps(data_dump), mimetype='application/json')
def static_graph_data(request, start, end, res): ''' A view returning the JSON data used to populate the static graph. ''' # Increase the viewCount for today data.increase_count(CUSTOM_GRAPH) data_dump = data._make_data_dump(start, end, res) json_serializer = serializers.get_serializer("json")() return HttpResponse(simplejson.dumps(data_dump), mimetype='application/json')