Skip to content

Commit

Permalink
support test_ids filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
dapollak committed Jan 19, 2025
1 parent fb3e32d commit 81c9cf3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions elementary/monitor/data_monitoring/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class FiltersSchema(BaseModel):
models: List[FilterSchema] = Field(default_factory=list)
statuses: List[StatusFilterSchema] = Field(default=_get_default_statuses_filter())
resource_types: List[ResourceTypeFilterSchema] = Field(default_factory=list)
test_ids: List[FilterSchema[str]] = Field(default_factory=list)

@validator("invocation_time", pre=True)
def format_invocation_time(cls, invocation_time) -> Optional[str]:
Expand Down Expand Up @@ -255,6 +256,7 @@ def apply(
statuses: List[Status],
resource_types: List[ResourceType],
node_names: List[str],
test_ids: List[str],
) -> bool:
return (
all(
Expand Down Expand Up @@ -284,8 +286,19 @@ def apply(
if self.node_names
else True
)
and all(
filter_schema.apply_filter_on_values(test_ids)
for filter_schema in self.test_ids
)
)

def __gt__(self, other: 'FiltersSchema'):
if self.test_ids and not other.test_ids:
return True
if not self.test_ids and other.test_ids:
return False

return True

class SelectorFilterSchema(BaseModel):
selector: Optional[str] = None
Expand Down

0 comments on commit 81c9cf3

Please sign in to comment.