8282)
8383from sentry .seer .autofix .utils import (
8484 AutofixTriggerSource ,
85+ bulk_read_preferences_from_sentry_db ,
8586 get_project_seer_preferences ,
87+ read_preference_from_sentry_db ,
8688 resolve_repository_ids ,
8789 write_preference_to_sentry_db ,
8890)
@@ -861,6 +863,23 @@ def check_repository_integrations_status(*, repository_integrations: list[dict[s
861863 return {"integration_ids" : integration_ids }
862864
863865
866+ def get_project_preferences (* , organization_id : int , project_id : int ) -> dict | None :
867+ try :
868+ project = Project .objects .get (id = project_id , organization_id = organization_id )
869+ except Project .DoesNotExist :
870+ return None
871+
872+ pref = read_preference_from_sentry_db (project )
873+ if pref is None :
874+ return None
875+ return pref .dict ()
876+
877+
878+ def bulk_get_project_preferences (* , organization_id : int , project_ids : list [int ]) -> dict :
879+ prefs = bulk_read_preferences_from_sentry_db (organization_id , project_ids )
880+ return {str (project_id ): pref .dict () if pref else None for project_id , pref in prefs .items ()}
881+
882+
864883seer_method_registry : dict [str , Callable ] = { # return type must be serialized
865884 # Common to Seer features
866885 "get_github_enterprise_integration_config" : get_github_enterprise_integration_config ,
@@ -877,6 +896,8 @@ def check_repository_integrations_status(*, repository_integrations: list[dict[s
877896 "send_seer_webhook" : send_seer_webhook ,
878897 "get_attributes_for_span" : get_attributes_for_span ,
879898 "trigger_coding_agent_launch" : trigger_coding_agent_launch ,
899+ "get_project_preferences" : get_project_preferences ,
900+ "bulk_get_project_preferences" : bulk_get_project_preferences ,
880901 #
881902 # Bug prediction
882903 "has_repo_code_mappings" : has_repo_code_mappings ,
0 commit comments