Feature/expose thresholds in rule settings (#3770)

pull/3771/head
Thomas Kaul 3 months ago committed by GitHub
parent 9fb80e5067
commit 3de192c65e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,6 +1,9 @@
import { RuleSettings } from '@ghostfolio/api/models/interfaces/rule-settings.interface';
import { Rule } from '@ghostfolio/api/models/rule';
import { UserSettings } from '@ghostfolio/common/interfaces';
import {
PortfolioReportRule,
UserSettings
} from '@ghostfolio/common/interfaces';
import { Injectable } from '@nestjs/common';
@ -11,19 +14,23 @@ export class RulesService {
public async evaluate<T extends RuleSettings>(
aRules: Rule<T>[],
aUserSettings: UserSettings
) {
): Promise<PortfolioReportRule[]> {
return aRules.map((rule) => {
if (rule.getSettings(aUserSettings)?.isActive) {
const { evaluation, value } = rule.evaluate(
rule.getSettings(aUserSettings)
);
const settings = rule.getSettings(aUserSettings);
if (settings?.isActive) {
const { evaluation, value } = rule.evaluate(settings);
return {
evaluation,
value,
isActive: true,
key: rule.getKey(),
name: rule.getName()
name: rule.getName(),
settings: <PortfolioReportRule['settings']>{
thresholdMax: settings['thresholdMax'],
thresholdMin: settings['thresholdMin']
}
};
} else {
return {

@ -3,5 +3,9 @@ export interface PortfolioReportRule {
isActive: boolean;
key: string;
name: string;
settings?: {
thresholdMax?: number;
thresholdMin?: number;
};
value?: boolean;
}

Loading…
Cancel
Save