Skip to content

Commit

Permalink
Make batch sizes configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Cruikshanks committed Sep 17, 2024
1 parent d2f9e0a commit 5917c4b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ S3_NALD_IMPORT_PATH=

WATER_SERVICE_MAILBOX=

# In processes like licence-details, configure how many 'things' to import within each batch
IMPORT_PROCESS_BATCH_SIZE=

# For development only! See https://eaflood.atlassian.net/browse/WATER-3201
# Enables import of licence agreements during the licence import process. This was a one time import
# run in production that we often need to re-run in local and non-production environments
Expand Down
3 changes: 3 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ module.exports = {

proxy: process.env.PROXY,

// In processes like licence-details, configure how many 'things' to import within each batch
processBatchSize: parseInt(process.env.IMPORT_PROCESS_BATCH_SIZE) || 10,

import: {
nald: {
zipPassword: process.env.NALD_ZIP_PASSWORD,
Expand Down
4 changes: 3 additions & 1 deletion src/modules/company-details/steps/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const db = require('../../../lib/connectors/db.js')
const { calculateAndLogTimeTaken, currentTimeInNanoseconds } = require('../../../lib/general.js')
const Loader = require('../lib/loader.js')

const config = require('../../../../config.js')

const PROGRESS_TICK = 1000

async function go () {
Expand Down Expand Up @@ -31,7 +33,7 @@ async function go () {
}

async function _import (parties, count) {
const batchSize = 10
const batchSize = config.processBatchSize

let progress = PROGRESS_TICK
let rejected = 0
Expand Down
4 changes: 3 additions & 1 deletion src/modules/licence-details/steps/licence-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const db = require('../../../lib/connectors/db.js')
const { calculateAndLogTimeTaken, currentTimeInNanoseconds } = require('../../../lib/general.js')
const Loader = require('../lib/loader.js')

const config = require('../../../../config.js')

const PROGRESS_TICK = 1000

async function go () {
Expand Down Expand Up @@ -31,7 +33,7 @@ async function go () {
}

async function _import (licences, count) {
const batchSize = 10
const batchSize = config.processBatchSize

let progress = PROGRESS_TICK
let rejected = 0
Expand Down
4 changes: 3 additions & 1 deletion src/modules/permit/steps/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const db = require('../../../lib/connectors/db.js')
const { calculateAndLogTimeTaken, currentTimeInNanoseconds } = require('../../../lib/general.js')
const Loader = require('../lib/loader.js')

const config = require('../../../../config.js')

const PROGRESS_TICK = 1000

async function go () {
Expand All @@ -30,7 +32,7 @@ async function go () {
}

async function _import (licenceReferences, count) {
const batchSize = 10
const batchSize = config.processBatchSize

let progress = PROGRESS_TICK
let rejected = 0
Expand Down

0 comments on commit 5917c4b

Please sign in to comment.