-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create settlement model on startup #320
base: main
Are you sure you want to change the base?
Conversation
src/shared/setup.js
Outdated
|
||
const createSettlementModels = async function (settlementModels = []) { | ||
try { | ||
// Get the existing settlement models |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need these comments?
src/shared/setup.js
Outdated
} | ||
|
||
// Find any new settlement models to be added | ||
const newSettlementModels = settlementModels.filter(a => !existingSettlementModels.some(b => b.name === a.name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactor into small function (naming should help clarify) without need for comments
for (const settlementModel of newSettlementModels) { | ||
Logger.info(`Creating settlement model: ${JSON.stringify(settlementModel)}`) | ||
const opts = { url, method: 'POST', data: settlementModel } | ||
await request(opts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure how many settlementModels are we going to create , but this could become a await Promise.all if there are a lot of them?
src/shared/setup.js
Outdated
/** | ||
* @function createSettlementModels | ||
* | ||
* @description Creates settlement models defined by config is not exists in database |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it does not exist in database
src/shared/setup.js
Outdated
const response = await request(opts) | ||
const existingSettlementModels = response.data | ||
|
||
if ((settlementModels == null || settlementModels.length < 1) && existingSettlementModels.length < 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactor if (!hasAtLeastOneSettlementModel) function helps with readability.
… to integration test runner.
Just an update that we are testing changes on settlementModels creation at startup that will address similarly but with a wider reaching solution for the community. |
@claudio-viola thanks for getting in touch- what time-frame are you expecting that to be completed, and is the implementation visible in GH at the moment? |
Shashi seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Quality Gate failedFailed conditions |
Summary: