Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: remove mutable defaults #187
  • Loading branch information
Angeluz-07 committed Jul 6, 2020
commit ad4d2cf5354671c8671c161bf851774c65455949
16 changes: 11 additions & 5 deletions commons/data_access_layer/cosmos_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ def __init__(
container_id: str,
partition_key_attribute: str,
mapper: Callable = None,
order_fields: list = [],
order_fields: list = None,
custom_cosmos_helper: CosmosDBFacade = None,
):
global cosmos_helper
self.cosmos_helper = custom_cosmos_helper or cosmos_helper
if self.cosmos_helper is None: # pragma: no cover
raise ValueError("The cosmos_db module has not been initialized!")
self.mapper = mapper
self.order_fields = order_fields
self.order_fields = order_fields if order_fields else []
self.container: ContainerProxy = self.cosmos_helper.db.get_container_client(
container_id
)
Expand Down Expand Up @@ -224,14 +224,20 @@ def find(
def find_all(
self,
event_context: EventContext,
conditions: dict = {},
custom_sql_conditions: List[str] = [],
custom_params: dict = {},
conditions: dict = None,
custom_sql_conditions: List[str] = None,
custom_params: dict = None,
max_count=None,
offset=0,
visible_only=True,
mapper: Callable = None,
):
conditions = conditions if conditions else {}
custom_sql_conditions = (
custom_sql_conditions if custom_sql_conditions else []
)
custom_params = custom_params if custom_params else {}

partition_key_value = self.find_partition_key_value(event_context)
max_count = self.get_page_size_or(max_count)
params = [
Expand Down
25 changes: 17 additions & 8 deletions time_tracker_api/time_entries/time_entries_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,15 @@ def create_sql_date_range_filter(date_range: dict) -> str:
def find_all_entries(
self,
event_context: EventContext,
conditions: dict = {},
conditions: dict = None,
custom_sql_conditions: List[str] = None,
date_range: dict = {},
date_range: dict = None,
):
if custom_sql_conditions is None:
custom_sql_conditions = []
conditions = conditions if conditions else {}
custom_sql_conditions = (
custom_sql_conditions if custom_sql_conditions else []
)
date_range = date_range if date_range else {}

custom_sql_conditions.append(
self.create_sql_date_range_filter(date_range)
Expand All @@ -184,11 +187,17 @@ def find_all_entries(
def find_all(
self,
event_context: EventContext,
conditions: dict = {},
custom_sql_conditions: List[str] = [],
date_range: dict = {},
conditions: dict = None,
custom_sql_conditions: List[str] = None,
date_range: dict = None,
**kwargs,
):
conditions = conditions if conditions else {}
custom_sql_conditions = (
custom_sql_conditions if custom_sql_conditions else []
)
date_range = date_range if date_range else {}

custom_sql_conditions.append(
self.create_sql_date_range_filter(date_range)
)
Expand Down Expand Up @@ -486,7 +495,7 @@ def find_running(self):
# self.stop_time_entry_if_was_left_running(time_entry)
return time_entry

def get_worked_time(self, args: dict = {}):
def get_worked_time(self, args: dict):
event_ctx = self.create_event_context(
"read", "Summary of worked time in the current month"
)
Expand Down