diff --git a/backend/analytics_server/mhq/service/incidents/sync/etl_handler.py b/backend/analytics_server/mhq/service/incidents/sync/etl_handler.py index f0aeef0e..f3c77ff8 100644 --- a/backend/analytics_server/mhq/service/incidents/sync/etl_handler.py +++ b/backend/analytics_server/mhq/service/incidents/sync/etl_handler.py @@ -6,7 +6,10 @@ SettingType, ) from mhq.store.models.settings.enums import EntityType -from mhq.service.settings.configuration_settings import get_settings_service +from mhq.service.settings.configuration_settings import ( + SettingsService, + get_settings_service, +) from mhq.service.incidents.integration import get_incidents_integration_service from mhq.service.incidents.sync.etl_incidents_factory import IncidentsETLFactory from mhq.service.incidents.sync.etl_provider_handler import IncidentsProviderETLHandler @@ -33,10 +36,12 @@ def __init__( provider: IncidentProvider, incident_repo_service: IncidentsRepoService, etl_service: IncidentsProviderETLHandler, + settings_service: SettingsService, ): self.provider = provider self.incident_repo_service = incident_repo_service self.etl_service = etl_service + self.settings_service = settings_service def sync_org_incident_services(self, org_id: str): try: @@ -61,7 +66,7 @@ def sync_org_incident_services(self, org_id: str): def _sync_service_incidents(self, service: OrgIncidentService): try: - default_sync_days_setting = get_settings_service().get_settings( + default_sync_days_setting = self.settings_service.get_settings( setting_type=SettingType.DEFAULT_SYNC_DAYS_SETTING, entity_type=EntityType.ORG, entity_id=str(service.org_id), @@ -118,7 +123,10 @@ def sync_org_incidents(org_id: str): try: incident_provider = IncidentProvider(provider) incidents_etl_handler = IncidentsETLHandler( - incident_provider, IncidentsRepoService(), etl_factory(provider) + incident_provider, + IncidentsRepoService(), + etl_factory(provider), + get_settings_service(), ) incidents_etl_handler.sync_org_incident_services(org_id) except Exception as e: diff --git a/backend/analytics_server/mhq/service/workflows/sync/etl_handler.py b/backend/analytics_server/mhq/service/workflows/sync/etl_handler.py index 781e165f..ff07b5ea 100644 --- a/backend/analytics_server/mhq/service/workflows/sync/etl_handler.py +++ b/backend/analytics_server/mhq/service/workflows/sync/etl_handler.py @@ -4,6 +4,7 @@ from uuid import uuid4 from mhq.service.settings.configuration_settings import ( + SettingsService, get_settings_service, ) from mhq.store.models.settings.configuration_settings import ( @@ -38,10 +39,12 @@ def __init__( code_repo_service: CodeRepoService, workflow_repo_service: WorkflowRepoService, etl_factory: WorkflowETLFactory, + settings_service: SettingsService, ): self.code_repo_service = code_repo_service self.workflow_repo_service = workflow_repo_service self.etl_factory = etl_factory + self.settings_service = settings_service def sync_org_workflows(self, org_id: str): active_repo_workflows: List[Tuple[OrgRepo, RepoWorkflow]] = ( @@ -95,7 +98,7 @@ def _sync_repo_workflow(self, org_repo: OrgRepo, repo_workflow: RepoWorkflow): LOG.error("Invalid PAT for code provider") return try: - default_sync_days_setting = get_settings_service().get_settings( + default_sync_days_setting = self.settings_service.get_settings( setting_type=SettingType.DEFAULT_SYNC_DAYS_SETTING, entity_type=EntityType.ORG, entity_id=str(org_repo.org_id), @@ -151,6 +154,6 @@ def sync_org_workflows(org_id: str): workflow_repo_service = WorkflowRepoService() etl_factory = WorkflowETLFactory(org_id) workflow_etl_handler = WorkflowETLHandler( - code_repo_service, workflow_repo_service, etl_factory + code_repo_service, workflow_repo_service, etl_factory, get_settings_service() ) workflow_etl_handler.sync_org_workflows(org_id)