Skip to content

Commit

Permalink
add group by grid id
Browse files Browse the repository at this point in the history
  • Loading branch information
daanvaningen committed Apr 25, 2024
1 parent d734871 commit f93cfcf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ History
2.2.8 (unreleased)
------------------

- Nothing changed yet.
- Add `group_by_grid_id` to structure control interface.


2.2.7 (2024-04-22)
Expand Down
11 changes: 9 additions & 2 deletions threedigrid/admin/gridresultadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ def group_by_id(self, id: str) -> Optional[StructureControl]:

return StructureControl(
id=id,
grid_id=grid_id,
source_table=source_table,
source_table_id=source_table_id,
time=self.time[mask],
Expand All @@ -454,6 +455,12 @@ def group_by_id(self, id: str) -> Optional[StructureControl]:
is_active=self.is_active[mask],
)

def group_by_grid_id(self, value: int) -> List[StructureControl]:
"""
Get all structure control actions with ``grid_id == value``
"""
return self._group_by("grid_id", value)

def group_by_action_type(self, value: str) -> List[StructureControl]:
"""
Get all structure control actions with ``action_type == value``
Expand All @@ -471,11 +478,11 @@ def group_by_time(self, min: float, max: float) -> List[StructureControl]:
return self._group_by_in_between("time", min, max)

def group_by_action_value_1(self, min: float, max: float) -> List[StructureControl]:
"""Get all structure control actions with ``action_value_1 == value``"""
"""Get all structure control actions where ``min <= action_value_1 <= max``"""
return self._group_by_in_between("action_value_1", min, max)

def group_by_action_value_2(self, min: float, max: float) -> List[StructureControl]:
"""Get all structure control actions with ``action_value_2 == value``"""
"""Get all structure control actions where ``min <= action_value_2 <= max``"""
return self._group_by_in_between("action_value_2", min, max)

def _group_by(
Expand Down
2 changes: 2 additions & 0 deletions threedigrid/admin/structure_controls/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class StructureControl:
def __init__(
self,
id: str,
grid_id: int,
source_table: str,
source_table_id: int,
time: List[float],
Expand All @@ -21,6 +22,7 @@ def __init__(
is_active: List[int],
) -> None:
self.id = id
self.grid_id = grid_id
self.source_table = source_table
self.source_table_id = source_table_id
self.time = time
Expand Down

0 comments on commit f93cfcf

Please sign in to comment.