generated from ubiquity/ts-template
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from gentlementlegen/feat/symbol-coefficient
feat!: symbol coefficients and configurable scores per group
- Loading branch information
Showing
34 changed files
with
6,191 additions
and
1,559 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 |
---|---|---|
@@ -1,27 +1,27 @@ | ||
import { Value } from "@sinclair/typebox/value"; | ||
import program from "../parser/command-line"; | ||
import { IncentivesConfiguration, incentivesConfigurationSchema, validateIncentivesConfiguration } from "./incentives"; | ||
import { Value } from "@sinclair/typebox/value"; | ||
import { merge } from "lodash"; | ||
|
||
let configuration: IncentivesConfiguration | null = null; | ||
|
||
try { | ||
const defaultConf = Value.Create(incentivesConfigurationSchema); | ||
configuration = Value.Decode(incentivesConfigurationSchema, defaultConf); | ||
configuration = Value.Default(incentivesConfigurationSchema, {}) as IncentivesConfiguration; | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
|
||
if (program.settings) { | ||
const settings = merge(configuration, JSON.parse(program.settings)); | ||
const settings = Value.Default( | ||
incentivesConfigurationSchema, | ||
JSON.parse(program.settings) | ||
) as IncentivesConfiguration; | ||
if (validateIncentivesConfiguration.test(settings)) { | ||
configuration = settings; | ||
configuration = Value.Decode(incentivesConfigurationSchema, settings); | ||
} else { | ||
console.warn("Invalid incentives configuration detected, will revert to defaults."); | ||
for (const error of validateIncentivesConfiguration.errors(settings)) { | ||
console.warn(error); | ||
} | ||
} | ||
} | ||
|
||
export default configuration as IncentivesConfiguration; |
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 |
---|---|---|
@@ -1,14 +1,17 @@ | ||
import { Static, Type } from "@sinclair/typebox"; | ||
|
||
export const dataCollectionConfigurationType = Type.Object({ | ||
/** | ||
* The maximum amount of retries on failure. | ||
*/ | ||
maxAttempts: Type.Number({ default: 10, minimum: 1 }), | ||
/** | ||
* The delay between each retry, in milliseconds. | ||
*/ | ||
delayMs: Type.Number({ default: 1000, minimum: 100 }), | ||
}); | ||
export const dataCollectionConfigurationType = Type.Object( | ||
{ | ||
/** | ||
* The maximum amount of retries on failure. | ||
*/ | ||
maxAttempts: Type.Number({ default: 10, minimum: 1 }), | ||
/** | ||
* The delay between each retry, in milliseconds. | ||
*/ | ||
delayMs: Type.Number({ default: 1000, minimum: 100 }), | ||
}, | ||
{ default: {} } | ||
); | ||
|
||
export type DataCollectionConfiguration = Static<typeof dataCollectionConfigurationType>; |
Oops, something went wrong.