Skip to content
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ To set up middleware locally, follow these steps:
REDIS_PORT=6385
ANALYTICS_SERVER_PORT=9696
SYNC_SERVER_PORT=9697
DEFAULT_SYNC_DAYS=31
```

- Start the backend servers
Expand Down
11 changes: 10 additions & 1 deletion backend/analytics_server/mhq/service/code/sync/etl_handler.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from os import getenv
from datetime import datetime, timedelta
from typing import List

Expand All @@ -19,6 +20,11 @@


class CodeETLHandler:

DEFAULT_SYNC_DAYS = (
int(getenv("DEFAULT_SYNC_DAYS")) if getenv("DEFAULT_SYNC_DAYS") else 31
)

def __init__(
self,
code_repo_service: CodeRepoService,
Expand Down Expand Up @@ -92,7 +98,10 @@ def __sync_revert_prs_mapping(
LOG.error(f"Error syncing revert PRs for repo {org_repo.name}: {str(e)}")
raise e

def __get_org_repo_bookmark(self, org_repo: OrgRepo, default_sync_days: int = 31):
def __get_org_repo_bookmark(
self, org_repo: OrgRepo, default_sync_days: int = DEFAULT_SYNC_DAYS
):

bookmark = self.code_repo_service.get_org_repo_bookmark(
org_repo, BookmarkType.PR
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from os import getenv
from datetime import timedelta
from typing import List

Expand All @@ -17,6 +18,11 @@


class IncidentsETLHandler:

DEFAULT_SYNC_DAYS = (
int(getenv("DEFAULT_SYNC_DAYS")) if getenv("DEFAULT_SYNC_DAYS") else 31
)

def __init__(
self,
provider: IncidentProvider,
Expand Down Expand Up @@ -67,7 +73,7 @@ def _sync_service_incidents(self, service: OrgIncidentService):
return

def __get_incidents_bookmark(
self, service: OrgIncidentService, default_sync_days: int = 31
self, service: OrgIncidentService, default_sync_days: int = DEFAULT_SYNC_DAYS
) -> IncidentsBookmark:
bookmark = self.incident_repo_service.get_incidents_bookmark(
str(service.id), IncidentBookmarkType.SERVICE, self.provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from mhq.utils.log import LOG
from mhq.utils.time import ISO_8601_DATE_FORMAT, time_now

DEFAULT_WORKFLOW_SYNC_DAYS = 31
WORKFLOW_PROCESSING_CHUNK_SIZE = 100


Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from os import getenv
from datetime import timedelta
from typing import List, Tuple
from uuid import uuid4
Expand All @@ -20,6 +21,11 @@


class WorkflowETLHandler:

DEFAULT_SYNC_DAYS = (
int(getenv("DEFAULT_SYNC_DAYS")) if getenv("DEFAULT_SYNC_DAYS") else 31
)

def __init__(
self,
code_repo_service: CodeRepoService,
Expand Down Expand Up @@ -99,7 +105,7 @@ def _sync_repo_workflow(self, org_repo: OrgRepo, repo_workflow: RepoWorkflow):
return

def __get_repo_workflow_bookmark(
self, repo_workflow: RepoWorkflow, default_sync_days: int = 31
self, repo_workflow: RepoWorkflow, default_sync_days: int = DEFAULT_SYNC_DAYS
) -> RepoWorkflowRunsBookmark:
repo_workflow_bookmark = (
self.workflow_repo_service.get_repo_workflow_runs_bookmark(repo_workflow.id)
Expand Down
1 change: 1 addition & 0 deletions env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ ANALYTICS_SERVER_PORT=9696
INTERNAL_API_BASE_URL=http://localhost:9696
INTERNAL_SYNC_API_BASE_URL=http://localhost:9697
NEXT_PUBLIC_APP_ENVIRONMENT="development"
DEFAULT_SYNC_DAYS=31