Skip to content

Commit 65ecaa8

Browse files
committed
fix: 🥅 return 204 when time-entry not found in running
1 parent 212ad84 commit 65ecaa8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

time_tracker_api/time_entries/time_entries_model.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,10 @@ def find_running(
310310
)
311311

312312
function_mapper = self.get_mapper_or_dict(mapper)
313-
return function_mapper(next(result))
313+
try:
314+
return function_mapper(next(result))
315+
except StopIteration as no_result:
316+
raise CustomError(HTTPStatus.NO_CONTENT)
314317

315318
def validate_data(self, data, event_context: EventContext):
316319
start_date = data.get('start_date')

time_tracker_api/time_entries/time_entries_namespace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def post(self, id):
292292

293293
@ns.route('/running')
294294
@ns.response(HTTPStatus.OK, 'The time entry that is active: currently running')
295-
@ns.response(HTTPStatus.NOT_FOUND, 'There is no time entry running right now')
295+
@ns.response(HTTPStatus.NO_CONTENT, 'There is no time entry running right now')
296296
class ActiveTimeEntry(Resource):
297297
@ns.doc('running_time_entry')
298298
@ns.marshal_with(time_entry)

0 commit comments

Comments
 (0)