Skip to content

Commit d4939c8

Browse files
authored
fix: TT-238 adds condition to control when there are no time entries … (#290)
* fix: TT-238 adds condition to control when there are no time entries records in get method * fix: TT-238 change code according sonar suggestion Co-authored-by: Pablo <Solorzano>
1 parent da354ae commit d4939c8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

time_tracker_api/time_entries/time_entries_repository.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ def count(
142142

143143
return result.next()
144144

145-
def add_complementary_info(self, time_entries=None, max_count=None):
145+
def add_complementary_info(
146+
self, time_entries=None, max_count=None, exist_conditions=False
147+
):
146148
if time_entries:
147149
custom_conditions = create_in_condition(time_entries, "project_id")
148150
custom_conditions_activity = create_in_condition(
@@ -168,7 +170,7 @@ def add_complementary_info(self, time_entries=None, max_count=None):
168170

169171
users = AzureConnection().users()
170172
add_user_email_to_time_entries(time_entries, users)
171-
elif not time_entries and len(conditions) > 1:
173+
elif not time_entries and exist_conditions:
172174
abort(HTTPStatus.NOT_FOUND, "Time entry not found")
173175
return time_entries
174176

@@ -230,8 +232,11 @@ def find_all(
230232

231233
function_mapper = self.get_mapper_or_dict(mapper)
232234
time_entries = list(map(function_mapper, result))
235+
exist_conditions = len(conditions) > 1
233236

234-
return self.add_complementary_info(time_entries, max_count)
237+
return self.add_complementary_info(
238+
time_entries, max_count, exist_conditions
239+
)
235240

236241
def create_sql_test_users_exclusion_condition(self, test_user_ids):
237242
if test_user_ids != None:

0 commit comments

Comments
 (0)