Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add SettingsService in the constructor of the classes using this service #507

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions backend/analytics_server/mhq/service/incidents/sync/etl_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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),
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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]] = (
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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)
Loading