Skip to content

Commit

Permalink
Add countrypage commands in cronjobs scheduled to everyweek
Browse files Browse the repository at this point in the history
  • Loading branch information
susilnem committed Jun 13, 2024
1 parent 85694a2 commit a1552bf
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 1 deletion.
3 changes: 3 additions & 0 deletions databank/management/commands/FDRS_INCOME.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
import requests
from django.conf import settings
from django.core.management.base import BaseCommand
from sentry_sdk.crons import monitor

from databank.models import CountryOverview, FDRSIncome, FDRSIndicator
from main.sentry import SentryMonitor

logger = logging.getLogger(__name__)


@monitor(monitor_slug=SentryMonitor.FDRS_INCOME)
class Command(BaseCommand):
help = "Import FDRS income data"

Expand Down
3 changes: 3 additions & 0 deletions databank/management/commands/fdrs_annual_income.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
import requests
from django.conf import settings
from django.core.management.base import BaseCommand
from sentry_sdk.crons import monitor

from databank.models import CountryOverview, FDRSAnnualIncome
from main.sentry import SentryMonitor

logger = logging.getLogger(__name__)


@monitor(monitor_slug=SentryMonitor.FDRS_ANNUAL_INCOME)
class Command(BaseCommand):
help = "Import FDRS income data"

Expand Down
3 changes: 3 additions & 0 deletions databank/management/commands/ingest_acaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
import requests
from django.conf import settings
from django.core.management.base import BaseCommand
from sentry_sdk.crons import monitor

from api.logger import logger
from api.models import CountryType
from databank.models import AcapsSeasonalCalender, CountryOverview
from main.sentry import SentryMonitor


@monitor(monitor_slug=SentryMonitor.INGEST_ACAPS)
class Command(BaseCommand):
help = "Add Acaps seasonal calender data"

Expand Down
3 changes: 3 additions & 0 deletions databank/management/commands/ingest_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

import requests
from django.core.management.base import BaseCommand
from sentry_sdk.crons import monitor

from api.models import CountryType
from databank.models import CountryKeyClimate, CountryOverview
from main.sentry import SentryMonitor

logger = logging.getLogger(__name__)


@monitor(monitor_slug=SentryMonitor.INGEST_CLIMATE)
class Command(BaseCommand):
help = "Add minimum, maximum and Average temperature of country temperature data from source api"

Expand Down
3 changes: 3 additions & 0 deletions databank/management/commands/ingest_databank.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

from django.core.management.base import BaseCommand
from django.utils import timezone
from sentry_sdk.crons import monitor

from api.models import Country, CronJob, CronJobStatus
from databank.models import CountryOverview
from main.sentry import SentryMonitor

from .sources import FDRS, FTS_HPC, INFORM, RELIEFWEB, START_NETWORK, WB

Expand All @@ -24,6 +26,7 @@
]


@monitor(monitor_slug=SentryMonitor.INGEST_DATABANK)
class Command(BaseCommand):
def load(self):
"""
Expand Down
3 changes: 3 additions & 0 deletions databank/management/commands/ingest_hdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import requests
from django.core.management.base import BaseCommand
from sentry_sdk.crons import monitor

from databank.models import CountryOverview as CO
from main.sentry import SentryMonitor

logger = logging.getLogger(__name__)


@monitor(monitor_slug=SentryMonitor.INGEST_HDR)
class Command(BaseCommand):
help = "Add HDR GII data"

Expand Down
3 changes: 3 additions & 0 deletions databank/management/commands/ingest_unicef.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import requests
from django.core.management.base import BaseCommand
from sentry_sdk.crons import monitor

from databank.models import CountryOverview as CO
from main.sentry import SentryMonitor

logger = logging.getLogger(__name__)


@monitor(monitor_slug=SentryMonitor.INGEST_UNICEF)
class Command(BaseCommand):
help = "Add Unicef population data"

Expand Down
3 changes: 3 additions & 0 deletions databank/management/commands/ingest_worldbank.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@

import requests
from django.core.management.base import BaseCommand
from sentry_sdk.crons import monitor

from api.models import Country, CountryType
from databank.models import CountryOverview as CO
from main.sentry import SentryMonitor

from .sources.utils import get_country_by_iso3

logger = logging.getLogger(__name__)


@monitor(monitor_slug=SentryMonitor.INGEST_WORLDBANK)
class Command(BaseCommand):
help = "Add Acaps seasonal calendar data"

Expand Down
17 changes: 16 additions & 1 deletion deploy/helm/ifrcgo-helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,22 @@ cronjobs:
schedule: '1 0 * * *'
- command: 'update_surge_alert_status'
schedule: '1 */12 * * *'

- command: 'fdrs_annual_income'
schedule: '0 0 * * 0'
- command: 'FDRS_INCOME'
schedule: '0 0 * * 0'
- command: 'ingest_acaps'
schedule: '0 0 * * *'
- command: 'ingest_climate'
schedule: '0 0 * * *'
- command: 'ingest_databank'
schedule: '0 0 * * *'
- command: 'ingest_hdr'
schedule: '0 0 * * *'
- command: 'ingest_unicef'
schedule: '0 0 * * *'
- command: 'ingest_worldbank'
schedule: '0 0 * * *'

elasticsearch:
enabled: true
Expand Down
8 changes: 8 additions & 0 deletions main/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ class SentryMonitor(models.TextChoices):
USER_REGISTRATION_REMINDER = "user_registration_reminder", "0 9 * * *"
INGEST_COUNTRY_PLAN_FILE = "ingest_country_plan_file", "1 0 * * *"
UPDATE_SURGE_ALERT_STATUS = "update_surge_alert_status", "1 */12 * * *"
FDRS_ANNUAL_INCOME = "fdrs_annual_income", "0 0 * * 0"
FDRS_INCOME = "FDRS_INCOME", "0 0 * * 0"
INGEST_ACAPS = "ingest_acaps", "0 0 * * *"
INGEST_CLIMATE = "ingest_climate", "0 0 * * *"
INGEST_DATABANK = "ingest_databank", "0 0 * * *"
INGEST_HDR = "ingest_hdr", "0 0 * * *"
INGEST_UNICEF = "ingest_unicef", "0 0 * * *"
INGEST_WORLDBANK = "ingest_worldbank", "0 0 * * *"

@staticmethod
def load_cron_data() -> typing.List[typing.Tuple[str, str]]:
Expand Down

0 comments on commit a1552bf

Please sign in to comment.