@@ -24,13 +24,6 @@ def create_package_subscription_notifications(
2424 )
2525 cve_id = suggestion .cve .cve_id
2626
27- # Query maintainers' GitHub usernames directly from the derivations' metadata
28- maintainers_github = list (
29- suggestion .derivations .filter (metadata__maintainers__isnull = False )
30- .values_list ("metadata__maintainers__github" , flat = True )
31- .distinct ()
32- )
33-
3427 if not affected_packages :
3528 logger .debug (f"No packages found for suggestion { suggestion .pk } " )
3629 return
@@ -41,19 +34,23 @@ def create_package_subscription_notifications(
4134 ).select_related ("profile" )
4235 subscribed_users_set = set (subscribed_users_qs )
4336
44- # Find maintainers of affected packages from cached suggestion
45- maintainer_users = set ()
46- if maintainers_github :
47- maintainer_users = set (
48- User .objects .filter (
49- username__in = maintainers_github ,
50- profile__auto_subscribe_to_maintained_packages = True ,
51- ).select_related ("profile" )
37+ # Find maintainers of affected packages with auto-subscribe enabled
38+ maintainer_users_qs = (
39+ User .objects .filter (
40+ username__in = suggestion .derivations .filter (
41+ metadata__maintainers__isnull = False
42+ ).values_list ("metadata__maintainers__github" , flat = True ),
43+ profile__auto_subscribe_to_maintained_packages = True ,
5244 )
45+ .select_related ("profile" )
46+ .distinct ()
47+ )
5348
54- logger .debug (
55- f"Found { len (maintainer_users )} maintainers with auto-subscribe enabled for suggestion { suggestion .pk } "
56- )
49+ maintainer_users = set (maintainer_users_qs )
50+
51+ logger .debug (
52+ f"Found { len (maintainer_users )} maintainers with auto-subscribe enabled for suggestion { suggestion .pk } "
53+ )
5754
5855 # Combine both sets of users, avoiding duplicates
5956 all_users_to_notify = subscribed_users_set | maintainer_users
0 commit comments