diff --git a/database/src/seeds/04_mock_test_data.ts b/database/src/seeds/04_mock_test_data.ts index 21842c6e0..a46c22210 100644 --- a/database/src/seeds/04_mock_test_data.ts +++ b/database/src/seeds/04_mock_test_data.ts @@ -3,8 +3,9 @@ import { faker } from '@faker-js/faker'; import random from 'geojson-random'; import { Knex } from 'knex'; -// Disable mock data seeding by default, unless manually enabled -const ENABLED = false; +// Disable mock data seeding by default. Set `ENABLE_MOCK_FEATURE_DATA=true` to enable. +const ENABLE_MOCK_FEATURE_SEEDING = Boolean(process.env.ENABLE_MOCK_FEATURE_SEEDING === 'true' || false); +const NUM_MOCK_FEATURE_SUBMISSIONS = Number(process.env.NUM_MOCK_FEATURE_SUBMISSIONS || 0); /** * Sample query for performance testing. @@ -40,7 +41,7 @@ const ENABLED = false; * @return {*} {Promise} */ export async function seed(knex: Knex): Promise { - if (!ENABLED) { + if (!ENABLE_MOCK_FEATURE_SEEDING) { return knex.raw(`SELECT null;`); // dummy query to appease knex } @@ -49,9 +50,7 @@ export async function seed(knex: Knex): Promise { SET SEARCH_PATH = 'biohub','public'; `); - const numSubmissions = 10000; // Number of submissions (ie: surveys) - - for (let i = 0; i < numSubmissions; i++) { + for (let i = 0; i < NUM_MOCK_FEATURE_SUBMISSIONS; i++) { await insertRecord(knex); } } diff --git a/env_config/env.docker b/env_config/env.docker index bcaecad14..7b42778fc 100644 --- a/env_config/env.docker +++ b/env_config/env.docker @@ -151,3 +151,11 @@ GEOSERVER_ADMIN_PASSWORD=geoserver ROOT_WEBAPP_REDIRECT=true TOMCAT_EXTRAS=false + +# ------------------------------------------------------------------------------ +# Seeding - Development +# ------------------------------------------------------------------------------ +# Enable or disable the mock data seeding in '04_mock_test_data.ts' +ENABLE_MOCK_FEATURE_SEEDING=false +# Configure how many feature submission records to seed +NUM_MOCK_FEATURE_SUBMISSIONS=0