Skip to content

Commit

Permalink
Add country page related cronjob
Browse files Browse the repository at this point in the history
  • Loading branch information
susilnem committed Jun 18, 2024
1 parent a1552bf commit 1c7bac1
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 14 deletions.
3 changes: 3 additions & 0 deletions api/management/commands/ingest_disaster_law.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import requests
from bs4 import BeautifulSoup
from django.core.management.base import BaseCommand
from sentry_sdk.crons import monitor

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


@monitor(monitor_slug=SentryMonitor.INGEST_DISASTER_LAW)
class Command(BaseCommand):
help = "Add ICRC data"

Expand Down
3 changes: 3 additions & 0 deletions api/management/commands/ingest_icrc.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import requests
from bs4 import BeautifulSoup
from django.core.management.base import BaseCommand
from sentry_sdk.crons import monitor

from api.logger import logger
from api.models import Country, CountryICRCPresence, CronJob, CronJobStatus
from main.sentry import SentryMonitor


@monitor(monitor_slug=SentryMonitor.INGEST_ICRC)
class Command(BaseCommand):
help = "Add ICRC data"

Expand Down
5 changes: 4 additions & 1 deletion api/management/commands/ingest_ns_capacity.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
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 Country, CountryCapacityStrengthening, CronJob, CronJobStatus
from main.sentry import SentryMonitor


@monitor(monitor_slug=SentryMonitor.INGEST_NS_CAPACITY)
class Command(BaseCommand):
help = "Add ns contact details"

Expand Down Expand Up @@ -44,7 +47,7 @@ def handle(self, *args, **kwargs):
text_to_log = "%s Ns capacity added" % ocaa_count
logger.info(text_to_log)
body = {
"name": "ingest_ns_capaciity",
"name": "ingest_ns_capacity",
"message": text_to_log,
"num_result": ocaa_count,
"status": CronJobStatus.SUCCESSFUL,
Expand Down
3 changes: 3 additions & 0 deletions api/management/commands/ingest_ns_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
from django.conf import settings
from django.core.management.base import BaseCommand
from requests.auth import HTTPBasicAuth
from sentry_sdk.crons import monitor

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


@monitor(monitor_slug=SentryMonitor.INGEST_NS_CONTACT)
class Command(BaseCommand):
help = "Add ns contact details"

Expand Down
3 changes: 3 additions & 0 deletions api/management/commands/ingest_ns_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
from django.conf import settings
from django.core.management.base import BaseCommand
from requests.auth import HTTPBasicAuth
from sentry_sdk.crons import monitor

from api.logger import logger
from api.models import Country, CountryDirectory, CronJob, CronJobStatus
from main.sentry import SentryMonitor


@monitor(monitor_slug=SentryMonitor.INGEST_NS_DIRECTORY)
class Command(BaseCommand):
help = "Add ns contact details"

Expand Down
3 changes: 3 additions & 0 deletions api/management/commands/ingest_ns_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
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 Country, CountryKeyDocument, CronJob, CronJobStatus
from main.sentry import SentryMonitor


@monitor(monitor_slug=SentryMonitor.INGEST_NS_DOCUMENT)
class Command(BaseCommand):
help = "Add ns documents"

Expand Down
3 changes: 3 additions & 0 deletions api/management/commands/ingest_ns_initiatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
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 Country, CronJob, CronJobStatus, NSDInitiatives
from main.sentry import SentryMonitor


@monitor(monitor_slug=SentryMonitor.INGEST_NS_INITIATIVES)
class Command(BaseCommand):
help = "Add ns initiatives"

Expand Down
1 change: 0 additions & 1 deletion databank/management/commands/ingest_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

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
Expand Down
27 changes: 21 additions & 6 deletions deploy/helm/ifrcgo-helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,32 @@ cronjobs:
- command: 'FDRS_INCOME'
schedule: '0 0 * * 0'
- command: 'ingest_acaps'
schedule: '0 0 * * *'
schedule: '0 0 * * 0'
- command: 'ingest_climate'
schedule: '0 0 * * *'
schedule: '0 0 * * 0'
- command: 'ingest_databank'
schedule: '0 0 * * *'
schedule: '0 0 * * 0'
- command: 'ingest_hdr'
schedule: '0 0 * * *'
schedule: '0 0 * * 0'
- command: 'ingest_unicef'
schedule: '0 0 * * *'
schedule: '0 0 * * 0'
- command: 'ingest_worldbank'
schedule: '0 0 * * *'
schedule: '0 0 * * 0'
- command: 'ingest_disaster_law'
schedule: '0 0 * * 0'
- command: 'ingest_ns_contact'
schedule: '0 0 * * 0'
- command: 'ingest_ns_capacity'
schedule: '0 0 * * 0'
- command: 'ingest_ns_directory'
schedule: '0 0 * * 0'
- command: 'ingest_ns_document'
schedule: '0 0 * * 0'
- command: 'ingest_ns_initiatives'
schedule: '0 0 * * 0'
- command: 'ingest_icrc'
schedule: '0 0 * * 0'


elasticsearch:
enabled: true
Expand Down
19 changes: 13 additions & 6 deletions main/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,19 @@ class SentryMonitor(models.TextChoices):
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 * * *"
INGEST_ACAPS = "ingest_acaps", "0 0 * * 0"
INGEST_CLIMATE = "ingest_climate", "0 0 * * 0"
INGEST_DATABANK = "ingest_databank", "0 0 * * 0"
INGEST_HDR = "ingest_hdr", "0 0 * * 0"
INGEST_UNICEF = "ingest_unicef", "0 0 * * 0"
INGEST_WORLDBANK = "ingest_worldbank", "0 0 * * 0"
INGEST_DISASTER_LAW = "ingest_disaster_law", "0 0 * * 0"
INGEST_NS_CONTACT = "ingest_ns_contact", "0 0 * * 0"
INGEST_NS_CAPACITY = "ingest_ns_capacity", "0 0 * * 0"
INGEST_NS_DIRECTORY = "ingest_ns_directory", "0 0 * * 0"
INGEST_NS_DOCUMENT = "ingest_ns_document", "0 0 * * 0"
INGEST_NS_INITIATIVES = "ingest_ns_initiatives", "0 0 * * 0"
INGEST_ICRC = "ingest_icrc", "0 0 * * 0"

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

0 comments on commit 1c7bac1

Please sign in to comment.