Skip to content

Commit e1721f8

Browse files
authored
Merge pull request #185 from ioet/fix/running-return-204
fix: 🥅 return 204 when time-entry not found in running
2 parents e35ad5a + 65ecaa8 commit e1721f8

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
@@ -313,7 +313,10 @@ def find_running(
313313
)
314314

315315
function_mapper = self.get_mapper_or_dict(mapper)
316-
return function_mapper(next(result))
316+
try:
317+
return function_mapper(next(result))
318+
except StopIteration as no_result:
319+
raise CustomError(HTTPStatus.NO_CONTENT)
317320

318321
def validate_data(self, data, event_context: EventContext):
319322
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)