Skip to content

Commit

Permalink
support the ignore_allocation_ids follow-up constraint to let SP canc…
Browse files Browse the repository at this point in the history
…el a trigger if there is already a pending or completed trigger with any allocation from that list
  • Loading branch information
Theodlz committed Aug 20, 2024
1 parent a91c8e2 commit 6966860
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
24 changes: 21 additions & 3 deletions kowalski/alert_brokers/alert_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,13 @@ def alert_filter__user_defined(
)
)
),
"ignore_allocation_ids": list(
set(
_filter["auto_followup"].get(
"ignore_allocation_ids", []
)
)
),
"payload": payload,
# constraints
"source_group_ids": [_filter["group_id"]],
Expand Down Expand Up @@ -2229,9 +2236,20 @@ def alert_sentinel_skyportal(
for (i, r) in enumerate(existing_requests)
if r["allocation_id"]
== passed_filter["auto_followup"]["data"]["allocation_id"]
and not set(
passed_filter["auto_followup"]["data"]["target_group_ids"]
).isdisjoint(set([g["id"] for g in r.get("target_groups", [])]))
and (
not set(
passed_filter["auto_followup"]["data"]["target_group_ids"]
).isdisjoint(set([g["id"] for g in r.get("target_groups", [])]))
or (
len(
passed_filter["auto_followup"]["data"][
"target_group_ids"
]
)
== 0
and len(r.get("target_groups", [])) == 0
)
)
and compare_dicts(
passed_filter["auto_followup"]["data"]["payload"],
r["payload"],
Expand Down
1 change: 1 addition & 0 deletions kowalski/api/handlers/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"allocation_id": str,
"payload": dict,
"target_group_ids": list,
"ignore_allocation_ids": list,
"radius": float,
"validity_days": int,
"priority_order": str,
Expand Down

0 comments on commit 6966860

Please sign in to comment.