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
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
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