File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515
1616@job
1717def evaluate_product_rules_task (product_uuid ):
18- """Evaluate all active PolicyRules for the given product UUID ."""
18+ """Evaluate all active PolicyRules for the given product."""
1919 Product = apps .get_model ("product_portfolio" , "product" )
2020
2121 try :
@@ -27,9 +27,13 @@ def evaluate_product_rules_task(product_uuid):
2727
2828
2929@job
30- def evaluate_all_products_rules_task ():
31- """Enqueue evaluate_product_rules_task for every product."""
30+ def evaluate_all_products_rules_task (include_locked = False ):
31+ """Enqueue evaluate_product_rules_task for every product, skipping locked ones by default ."""
3232 Product = apps .get_model ("product_portfolio" , "product" )
3333
34- for product in Product .objects .select_related ("dataspace" ).all ():
34+ products = Product .objects .select_related ("dataspace" )
35+ if not include_locked :
36+ products = products .exclude_locked ()
37+
38+ for product in products :
3539 evaluate_product_rules_task .delay (product_uuid = product .uuid )
Original file line number Diff line number Diff line change @@ -140,6 +140,9 @@ class Meta(BaseStatusMixin.Meta):
140140
141141
142142class ProductQuerySet (DataspacedQuerySet ):
143+ def exclude_locked (self ):
144+ return self .exclude (configuration_status__is_locked = True )
145+
143146 def with_risk_threshold (self ):
144147 return self .annotate (
145148 risk_threshold = Coalesce (
@@ -287,7 +290,7 @@ def get_queryset(
287290 ).scope (user .dataspace )
288291
289292 if exclude_locked :
290- queryset = queryset .exclude ( configuration_status__is_locked = True )
293+ queryset = queryset .exclude_locked ( )
291294
292295 if include_inactive :
293296 return queryset
You can’t perform that action at this time.
0 commit comments