Possible fix for timestamp issue

Changes to be committed:
	modified:   server/src/server_api.py
This commit is contained in:
2023-09-25 00:11:06 +03:30
parent 6420ade9e2
commit 666eb9b44a

View File

@@ -133,11 +133,10 @@ def get_all_records():
# Route to get records since a given timestamp # Route to get records since a given timestamp
@app.route( @app.route(
'/get_records_since/<timestamp_str>', '/get_records_since/<timestamp>',
methods=['GET'] methods=['GET']
) )
def get_records_since(timestamp_str): def get_records_since(timestamp):
timestamp = parse_timestamp(timestamp_str)
if timestamp is None: if timestamp is None:
return jsonify({'error': 'Invalid timestamp format'}), 400 return jsonify({'error': 'Invalid timestamp format'}), 400
@@ -162,13 +161,11 @@ def get_records_since(timestamp_str):
# Route to get records between two timestamps # Route to get records between two timestamps
@app.route( @app.route(
'/get_records_between/' '/get_records_between/'
'<start_timestamp_str>/<end_timestamp_str>', '<start_timestamp>/<end_timestamp>',
methods=['GET'] methods=['GET']
) )
def get_records_between(start_timestamp_str, end_timestamp_str): def get_records_between(start_timestamp, end_timestamp):
# Parse the provided start and end timestamps into datetime objects # Parse the provided start and end timestamps into datetime objects
start_timestamp = parse_timestamp(start_timestamp_str)
end_timestamp = parse_timestamp(end_timestamp_str)
if start_timestamp is None or end_timestamp is None: if start_timestamp is None or end_timestamp is None:
return jsonify({'error': 'Invalid timestamp format'}), 400 return jsonify({'error': 'Invalid timestamp format'}), 400
@@ -189,9 +186,8 @@ def get_records_between(start_timestamp_str, end_timestamp_str):
return jsonify(records_list) return jsonify(records_list)
# Route to get records until a given timestamp # Route to get records until a given timestamp
@app.route('/get_records_until/<timestamp_str>', methods=['GET']) @app.route('/get_records_until/<timestamp>', methods=['GET'])
def get_records_until(timestamp_str): def get_records_until(timestamp):
timestamp = parse_timestamp(timestamp_str)
if timestamp is None: if timestamp is None:
return jsonify({'error': 'Invalid timestamp format'}), 400 return jsonify({'error': 'Invalid timestamp format'}), 400