Esempio n. 1
0
def test_high_chart(request):

    nowTime = apitimer.get_now_time_without_second()
    string_time = apitimer.get_string_time(nowTime)
    value = random.randint(1, 100)

    return HttpResponse(json.dumps({'x': '', 'y': value}), content_type='application/json')
Esempio n. 2
0
def get_temp_list(request, interval, unit):

    interval_time = 30
    type = '1min'

    if unit == 'min':
        type = '%s%s' % (interval, 'm')
        interval_time = interval_time * int(interval)
    elif unit == 'hour':
        type = '%s%s' % (interval, 'h')
        interval_time = interval_time * int(interval) * 60
    elif unit == 'day':
        type = '%s%s' % (interval, 'd')
        interval_time = interval_time * int(interval) * 24 * 60

    # logger.debug(type)
    # logger.debug(interval_time)

    print interval, unit


    end_time = apitimer.get_now_time_without_second()
    start_time = end_time - timedelta(minutes=interval_time)
    temp_list = accessdb.get_temp_record_between_two_point_time(start_time, end_time, type)
    detail_temp_list = {}
    for record in temp_list:
        detail = {}
        detail['time'] = apitimer.get_string_time(record.time)
        detail['value'] = record.value

        detail_temp_list[record.id] = detail

    return HttpResponse(json.dumps({'status': True, 'temp_list': detail_temp_list}), content_type='application/json')