Skip to content

Commit ed1597d

Browse files
PabloPablo
authored andcommitted
fix: TT-220 code adjustments
1 parent e37d347 commit ed1597d

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

commons/data_access_layer/cosmos_db.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,9 @@ def attach_context(data: dict, event_context: EventContext):
206206
"session_id": event_context.session_id,
207207
}
208208

209-
@staticmethod
210-
def validate_date_range(date_range: dict) -> bool:
211-
return 'start_date' and 'end_date' in date_range
212-
213209
@staticmethod
214210
def create_sql_date_range_filter(date_range: dict) -> str:
215-
if CosmosDBRepository.validate_date_range(date_range):
211+
if 'start_date' in date_range and 'end_date' in date_range:
216212
return """
217213
AND ((c.start_date BETWEEN @start_date AND @end_date) OR
218214
(c.end_date BETWEEN @start_date AND @end_date))
@@ -255,10 +251,10 @@ def find_all(
255251
event_context: EventContext,
256252
conditions: dict = None,
257253
visible_only=True,
254+
mapper: Callable = None,
258255
max_count=None,
259256
offset=0,
260257
date_range: dict = None,
261-
mapper: Callable = None,
262258
):
263259
conditions = conditions if conditions else {}
264260
partition_key_value = self.find_partition_key_value(event_context)

tests/time_tracker_api/projects/projects_model_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ def test_find_all_projects_new_version(
2929
project_repository.container.query_items = query_items_mock
3030

3131
result = project_repository.find_all(
32-
event_context, {"customer_id": "1"}, ['id'], ['customer_id']
32+
event_context=event_context,
33+
conditions={"customer_id": "1"},
34+
project_ids=['id'],
35+
customer_ids=['customer_id'],
3336
)
3437
find_partition_key_value_mock.assert_called_once()
3538
assert len(result) == 1

time_tracker_api/activities/activities_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ def find_all(
9191
event_context: EventContext,
9292
conditions: dict = None,
9393
visible_only=True,
94+
mapper: Callable = None,
9495
max_count=None,
9596
offset=0,
9697
activities_id: List = None,
97-
mapper: Callable = None,
9898
):
9999
query_builder = (
100100
CosmosDBQueryBuilder()

time_tracker_api/projects/projects_model.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ def find_all(
7373
event_context: EventContext,
7474
conditions: dict = None,
7575
visible_only=True,
76+
mapper: Callable = None,
7677
project_ids: List[str] = None,
7778
customer_ids: List[str] = None,
78-
mapper: Callable = None,
7979
):
8080
params = self.generate_params(conditions) if conditions else []
8181

@@ -117,7 +117,6 @@ def get_all(
117117
max_count=kwargs.get('max_count', None)
118118
)
119119

120-
# TODO: evaluate another approach in order that memory filtering will be make in Database instead
121120
customers_id = [
122121
customer.id
123122
for customer in customers

0 commit comments

Comments
 (0)