Skip to content

Commit

Permalink
fixed support for single or multiple advanced params
Browse files Browse the repository at this point in the history
  • Loading branch information
anisbhsl committed Feb 27, 2024
1 parent 1a7e69b commit 21b5c3d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pynequa/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, List, Optional
from typing import Dict, List, Optional, Union
from abc import abstractmethod, ABC
from dataclasses import dataclass, field
from loguru import logger
Expand Down Expand Up @@ -168,7 +168,7 @@ class QueryParams(AbstractParams):
aggregations: Optional[List[str]] = field(default_factory=lambda: [])
order_by: Optional[str] = None
group_by: Optional[str] = None
advanced: Optional[List[AdvancedParams]] = field(
advanced: Optional[Union[AdvancedParams, List[AdvancedParams]]] = field(
default_factory=lambda: [])
debug: bool = False

Expand Down Expand Up @@ -256,9 +256,14 @@ def _prepare_query_args(self, query_name: str) -> Dict:
if self.group_by is not None:
params["groupBy"] = self.group_by

if len(self.advanced) > 0:
advanced = (
[self.advanced]
if isinstance(self.advanced, AdvancedParams)
else self.advanced
)
if len(advanced) > 0:
advanced_param_payload = {}
for advanced_param in self.advanced:
for advanced_param in advanced:
column_name = advanced_param.col_name
payload_value = advanced_param.generate_payload()[column_name]
if column_name in advanced_param_payload:
Expand Down

0 comments on commit 21b5c3d

Please sign in to comment.