Пример #1
0
def get_sleep(username):
    timestamps = Timestamps.get_timestamps(username)
    http_status = 200 if timestamps else 404
    if timestamps is None:
        return jsonify({'timestamps': []}), http_status

    timestamps_list = [ts['timestamp'] for ts in timestamps]
    sleep = compute_sleep_time(timestamps_list)

    return jsonify({'sleep': sleep}), http_status
Пример #2
0
def get_sleep(username):
    timestamps = Timestamps.get_timestamps(username)
    http_status = 200 if timestamps else 404
    if timestamps is None:
        return jsonify({'timestamps': []}), http_status

    timestamps_list = [ts['timestamp'] for ts in timestamps]
    sleep = compute_sleep_time(timestamps_list)

    return jsonify({'sleep': sleep}), http_status
Пример #3
0
def get_timestamps(username):
    timestamps = Timestamps.get_timestamps(username)
    http_status = 200 if timestamps else 404
    if timestamps is None:
        timestamps = []
    return jsonify({'timestamps': timestamps}), http_status
Пример #4
0
def upload_timestamps(username):
    timestamps = request.get_json(force=True)
    status, message = Timestamps.upload(username, timestamps)
    http_status = 200 if status else 400
    return message, http_status
Пример #5
0
def get_timestamps(username):
    timestamps = Timestamps.get_timestamps(username)
    http_status = 200 if timestamps else 404
    if timestamps is None:
        timestamps = []
    return jsonify({'timestamps': timestamps}), http_status
Пример #6
0
def upload_timestamps(username):
    timestamps = request.get_json(force=True)
    status, message = Timestamps.upload(username, timestamps)
    http_status = 200 if status else 400
    return message, http_status