-
-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into renovate/peculiar-asn1-x509-2.x
- Loading branch information
Showing
241 changed files
with
14,453 additions
and
5,256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ typings | |
|
||
# test artifacts | ||
output/ | ||
!test/mocks/files/*.csv | ||
|
||
*.swp | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import '../../server/env'; | ||
|
||
import { sequelize } from '../../server/models'; | ||
|
||
import { runCheckThenExit } from './_utils'; | ||
|
||
async function checkTiersMinimumAmountWithPresets({ fix = false } = {}) { | ||
const message = 'Tiers presets cannot be lower than the minimum amount'; | ||
const results = await sequelize.query( | ||
` | ||
SELECT COUNT(*) AS count | ||
FROM "Tiers" | ||
WHERE presets IS NOT NULL | ||
AND ARRAY_LENGTH(presets, 1) > 0 | ||
AND "minimumAmount" > (SELECT MIN(val) FROM UNNEST(presets) val) | ||
`, | ||
{ type: sequelize.QueryTypes.SELECT, raw: true }, | ||
); | ||
|
||
if (results[0].count > 0) { | ||
if (!fix) { | ||
throw new Error(`${message} (${results[0].count} found)`); | ||
} | ||
|
||
await sequelize.query(` | ||
UPDATE "Tiers" | ||
SET | ||
"minimumAmount" = (SELECT MIN(val) FROM UNNEST(presets) val), | ||
"data" = JSONB_SET(COALESCE("data", '{}'), '{minimumAmountBeforeCheckFix}', "minimumAmount"::TEXT::JSONB) | ||
WHERE presets IS NOT NULL | ||
AND ARRAY_LENGTH(presets, 1) > 0 | ||
AND "minimumAmount" > (SELECT MIN(val) FROM UNNEST(presets) val) | ||
`); | ||
} | ||
} | ||
|
||
export async function checkTiers({ fix = false } = {}) { | ||
await checkTiersMinimumAmountWithPresets({ fix }); | ||
} | ||
|
||
if (!module.parent) { | ||
runCheckThenExit(checkTiers); | ||
} |
Oops, something went wrong.