Data Import Jobs - bcgov/nr-compliance-enforcement-cm GitHub Wiki

Overview

Data import jobs are defined as CLI commands in the NestJS backend.

A separate entrypoint to the Nest app is defined in /src/cli.ts, and can be run by specifying it in the start command.

nest start --entryFile=./src/cli.js

Specific commands and arguments can then be specified:

nest start --entryFile=./src/cli.js -- import -j parks

Commands are defined in app.commands.ts using the nest-commander library. Docs are available here.

Job Scheduling

Jobs are scheduled and executed using OpenShift's native CronJob definitions, defined in import-jobs.yaml in the backend templates:

image

Parks Import

Running Locally

Ensure the BC_PARKS_API_URL and BC_PARKS_API_KEY environment variables are set, then run the command below while the database is running and accessible:

nest start --entryFile=./src/cli.js -- import -j parks

A script for this is also defined in package.json, so you can run:

npm run import:parks

Running on Dev

There is a flag that determines if the import job runs for the dev environments, which is set to false by default. To run the job for your environment, set the global -> importEnabled flag to true in the values file for the desired environment:

image

Once this change is merged to main, the job is on a two hour schedule, so you will need to wait or manually create the job:

image

Make sure to revert this change after.