Skip to content

Commit

Permalink
Added is_active filter Model methods
Browse files Browse the repository at this point in the history
  • Loading branch information
muflone committed Feb 5, 2023
1 parent 8be945c commit a98cbbd
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pyodoo/v12/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def get_many(self,
return results

def all(self,
is_active: ActiveStatusChoice = ActiveStatusChoice.NOT_SET,
fields: tuple[str, ...] = None,
options: dict[str, Any] = None,
limit: Optional[int] = None,
Expand All @@ -209,6 +210,7 @@ def all(self,
"""
Get all the objects
:param is_active: Additional filter for active field
:param fields: Fields to include in the response
:param options: Dictionary with options to use
:param limit: Maximum number of results count
Expand All @@ -217,6 +219,7 @@ def all(self,
:return: List of dictionaries with the requested fields
"""
return self.filter(filters=[],
is_active=is_active,
fields=fields,
options=options,
limit=limit,
Expand Down Expand Up @@ -270,6 +273,7 @@ def find(self,

def filter(self,
filters: list[Union[BooleanOperator, Filter]],
is_active: ActiveStatusChoice = ActiveStatusChoice.NOT_SET,
fields: tuple[str, ...] = None,
options: dict[str, Any] = None,
limit: Optional[int] = None,
Expand All @@ -279,13 +283,17 @@ def filter(self,
Find some rows from a model using some filters
:param filters: List of filters used for searching the data
:param is_active: Additional filter for active field
:param fields: Tuple with the fields to include in the response
:param options: Dictionary with options to use
:param limit: Maximum number of results count
:param offset: Starting record number to fetch the data
:param order: Ordering clause
:return: List of dictionaries with the requested fields
"""
# Filter for active status
self._set_active(filters=filters,
is_active=is_active)
# Set options
if options is None:
options = {}
Expand All @@ -308,14 +316,20 @@ def filter(self,

def count(self,
filters: list[Union[BooleanOperator, Filter]],
is_active: ActiveStatusChoice = ActiveStatusChoice.NOT_SET,
options: dict[str, Any] = None) -> int:
"""
Get the rows count from a model using some filters
:param filters: List of filters used for searching the data
:param is_active: Additional filter for active field
:param options: Dictionary with options to use
:return: Rows count
"""
# Filter for active status
self._set_active(filters=filters,
is_active=is_active)
# Set options
if options is None:
options = {}
# Request data and get results
Expand All @@ -325,6 +339,7 @@ def count(self,

def search(self,
filters: list[Union[BooleanOperator, Filter]],
is_active: ActiveStatusChoice = ActiveStatusChoice.NOT_SET,
options: dict[str, Any] = None,
limit: Optional[int] = None,
offset: Optional[int] = None,
Expand All @@ -333,12 +348,16 @@ def search(self,
Find rows list from a list of filters
:param filters: List of filters used for searching the data
:param is_active: Additional filter for active field
:param options: Dictionary with options to use
:param limit: Maximum number of results count
:param offset: Starting record number to fetch the data
:param order: Ordering clause
:return: List of ID for the objects found
"""
# Filter for active status
self._set_active(filters=filters,
is_active=is_active)
# Set options
if options is None:
options = {}
Expand Down

0 comments on commit a98cbbd

Please sign in to comment.