To test the production for prediction issue3
This commit is contained in:
parent
1d8d228341
commit
0ece153621
@ -158,6 +158,17 @@ function validateNeutralityRules(input: {
|
||||
}
|
||||
}
|
||||
|
||||
function resolveNeutralityEnabled(
|
||||
globalEnabled: boolean | null | undefined,
|
||||
intervalOverride: boolean | null | undefined
|
||||
): boolean {
|
||||
// Global catalog toggle is the master switch: OFF disables every interval.
|
||||
if (globalEnabled === false) return false;
|
||||
// Interval may only further disable; null/undefined inherits global (on by default).
|
||||
if (intervalOverride === false) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function buildPoolNeutralityRules(
|
||||
global: repo.CandlePredictConfigRow,
|
||||
interval?: ResolvedInterval | null
|
||||
@ -166,10 +177,14 @@ function buildPoolNeutralityRules(
|
||||
minTolerancePercent: interval?.tieTolerancePercent ?? Number(global.tie_tolerance_percent),
|
||||
maxTolerancePercent:
|
||||
interval?.tieToleranceMaxPercent ?? Number(global.tie_tolerance_max_percent),
|
||||
minToleranceEnabled:
|
||||
interval?.tieToleranceMinEnabled ?? global.tie_tolerance_min_enabled ?? true,
|
||||
maxToleranceEnabled:
|
||||
interval?.tieToleranceMaxEnabled ?? global.tie_tolerance_max_enabled ?? true,
|
||||
minToleranceEnabled: resolveNeutralityEnabled(
|
||||
global.tie_tolerance_min_enabled,
|
||||
interval?.tieToleranceMinEnabled
|
||||
),
|
||||
maxToleranceEnabled: resolveNeutralityEnabled(
|
||||
global.tie_tolerance_max_enabled,
|
||||
interval?.tieToleranceMaxEnabled
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
@ -258,10 +273,14 @@ function resolveInterval(
|
||||
tieToleranceMaxPercent: Number(
|
||||
row.tie_tolerance_max_percent ?? global.tie_tolerance_max_percent
|
||||
),
|
||||
tieToleranceMinEnabled:
|
||||
row.tie_tolerance_min_enabled ?? global.tie_tolerance_min_enabled ?? true,
|
||||
tieToleranceMaxEnabled:
|
||||
row.tie_tolerance_max_enabled ?? global.tie_tolerance_max_enabled ?? true,
|
||||
tieToleranceMinEnabled: resolveNeutralityEnabled(
|
||||
global.tie_tolerance_min_enabled,
|
||||
row.tie_tolerance_min_enabled
|
||||
),
|
||||
tieToleranceMaxEnabled: resolveNeutralityEnabled(
|
||||
global.tie_tolerance_max_enabled,
|
||||
row.tie_tolerance_max_enabled
|
||||
),
|
||||
basePrice: Number(row.base_price ?? global.base_price),
|
||||
payoutMultiplier: Number(row.payout_multiplier ?? global.payout_multiplier),
|
||||
poolMultiplier: Number(row.pool_multiplier ?? global.pool_multiplier),
|
||||
@ -599,8 +618,25 @@ export async function updateAdminConfig(body: Record<string, unknown>) {
|
||||
|
||||
export async function listAdminIntervals() {
|
||||
const cfg = await repo.getConfig();
|
||||
const intervals = await loadResolvedIntervals(cfg, false);
|
||||
return intervals.map(mapIntervalDto);
|
||||
const rows = await repo.listAllIntervals();
|
||||
// Return raw override fields (null = inherit) so the admin form can show Inherit/On/Off.
|
||||
// Settlement still uses resolveInterval() which applies the global master switch.
|
||||
return rows.map((row) => {
|
||||
const resolved = resolveInterval(cfg, row);
|
||||
return {
|
||||
...mapIntervalDto(resolved),
|
||||
tieTolerancePercent:
|
||||
row.tie_tolerance_percent == null ? null : Number(row.tie_tolerance_percent),
|
||||
tieToleranceMaxPercent:
|
||||
row.tie_tolerance_max_percent == null ? null : Number(row.tie_tolerance_max_percent),
|
||||
tieToleranceMinEnabled: row.tie_tolerance_min_enabled,
|
||||
tieToleranceMaxEnabled: row.tie_tolerance_max_enabled,
|
||||
predictionWindowSeconds: row.prediction_window_seconds,
|
||||
payoutMultiplier: row.payout_multiplier == null ? null : Number(row.payout_multiplier),
|
||||
poolMultiplier: row.pool_multiplier == null ? null : Number(row.pool_multiplier),
|
||||
basePrice: row.base_price == null ? null : Number(row.base_price),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export async function createAdminInterval(body: Record<string, unknown>) {
|
||||
|
||||
@ -18,12 +18,12 @@ export function AdminPoolInsights({ config, interval, round }: Props) {
|
||||
const parts: string[] = [];
|
||||
const tieTolerancePercent = interval.tieTolerancePercent ?? config.tieTolerancePercent ?? 0;
|
||||
const tieToleranceMaxPercent = interval.tieToleranceMaxPercent ?? config.tieToleranceMaxPercent ?? 100;
|
||||
// Prefer resolved interval flags (same as settlement). Do not default to "on"
|
||||
// when the global catalog explicitly disabled the rules.
|
||||
// Prefer global catalog toggles as master switch (same as settlement).
|
||||
// Interval may only further disable — never re-enable rules the catalog turned off.
|
||||
const tieToleranceMinEnabled =
|
||||
interval.tieToleranceMinEnabled ?? config.tieToleranceMinEnabled ?? false;
|
||||
(config.tieToleranceMinEnabled ?? true) && interval.tieToleranceMinEnabled !== false;
|
||||
const tieToleranceMaxEnabled =
|
||||
interval.tieToleranceMaxEnabled ?? config.tieToleranceMaxEnabled ?? false;
|
||||
(config.tieToleranceMaxEnabled ?? true) && interval.tieToleranceMaxEnabled !== false;
|
||||
|
||||
if (tieToleranceMinEnabled) {
|
||||
parts.push(t('candlePredict.adminInsights.neutralMin', { percent: tieTolerancePercent }));
|
||||
|
||||
@ -80,16 +80,16 @@ export type CandlePredictInterval = {
|
||||
sortOrder: number;
|
||||
isDefault: boolean;
|
||||
isActive: boolean;
|
||||
predictionWindowSeconds: number;
|
||||
predictionWindowSeconds: number | null;
|
||||
maxPredictionWindowSeconds: number;
|
||||
/** Admin-only — not returned to players. */
|
||||
tieTolerancePercent?: number;
|
||||
tieToleranceMaxPercent?: number;
|
||||
tieToleranceMinEnabled?: boolean;
|
||||
tieToleranceMaxEnabled?: boolean;
|
||||
basePrice: number;
|
||||
payoutMultiplier: number;
|
||||
poolMultiplier: number;
|
||||
/** Admin-only — not returned to players. null = inherit global. */
|
||||
tieTolerancePercent?: number | null;
|
||||
tieToleranceMaxPercent?: number | null;
|
||||
tieToleranceMinEnabled?: boolean | null;
|
||||
tieToleranceMaxEnabled?: boolean | null;
|
||||
basePrice: number | null;
|
||||
payoutMultiplier: number | null;
|
||||
poolMultiplier: number | null;
|
||||
chartCandleLimit: number;
|
||||
};
|
||||
|
||||
|
||||
@ -85,16 +85,19 @@ function intervalToForm(row: CandlePredictInterval): FormState {
|
||||
sortOrder: row.sortOrder,
|
||||
isActive: row.isActive,
|
||||
isDefault: row.isDefault,
|
||||
predictionWindowSeconds: String(row.predictionWindowSeconds),
|
||||
tieTolerancePercent: '',
|
||||
tieToleranceMaxPercent: '',
|
||||
predictionWindowSeconds:
|
||||
row.predictionWindowSeconds == null ? '' : String(row.predictionWindowSeconds),
|
||||
tieTolerancePercent:
|
||||
row.tieTolerancePercent == null ? '' : String(row.tieTolerancePercent),
|
||||
tieToleranceMaxPercent:
|
||||
row.tieToleranceMaxPercent == null ? '' : String(row.tieToleranceMaxPercent),
|
||||
tieToleranceMinEnabled:
|
||||
row.tieToleranceMinEnabled == null ? 'inherit' : triFromBool(row.tieToleranceMinEnabled),
|
||||
tieToleranceMaxEnabled:
|
||||
row.tieToleranceMaxEnabled == null ? 'inherit' : triFromBool(row.tieToleranceMaxEnabled),
|
||||
payoutMultiplier: String(row.payoutMultiplier),
|
||||
poolMultiplier: String(row.poolMultiplier),
|
||||
basePrice: String(row.basePrice),
|
||||
payoutMultiplier: row.payoutMultiplier == null ? '' : String(row.payoutMultiplier),
|
||||
poolMultiplier: row.poolMultiplier == null ? '' : String(row.poolMultiplier),
|
||||
basePrice: row.basePrice == null ? '' : String(row.basePrice),
|
||||
chartCandleLimit: row.chartCandleLimit,
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user