fix: harden Structural S/R after OHLCV writes and surface cleanup failures
Deploy / lint (push) Successful in 8s
Deploy / test (push) Successful in 1m18s
Deploy / deploy (push) Successful in 40s

Honor custom S/R tolerance as a transient detect, refresh levels after OHLCV
mutations without failing committed price writes, report per-ticker S/R
rebuild failures from admin cleanup, and warn in the admin UI when refresh is partial.
This commit is contained in:
2026-07-18 13:44:34 +02:00
parent b0e33e1606
commit cad4b49e7c
11 changed files with 181 additions and 23 deletions
+24 -1
View File
@@ -404,7 +404,30 @@ export function useCleanupData() {
return useMutation({
mutationFn: (olderThanDays: number) => adminApi.cleanupData(olderThanDays),
onSuccess: (data) => {
addToast('success', (data as { message: string }).message || 'Cleanup completed');
const deleted =
(data.ohlcv ?? 0) + (data.sentiment ?? 0) + (data.fundamentals ?? 0);
const failed = data.sr_refresh_failed ?? 0;
if (failed > 0) {
const symbols = (data.sr_refresh_failures ?? [])
.map((f) => f.symbol)
.filter(Boolean);
const sample = symbols.slice(0, 8).join(', ');
const more = symbols.length > 8 ? ` (+${symbols.length - 8} more)` : '';
addToast(
'warning',
`Cleanup deleted ${deleted} row(s), but Structural S/R refresh failed for ${failed} ticker(s)` +
(sample ? `: ${sample}${more}` : '') +
'. Re-run the R:R scan or a per-ticker refresh to rebuild levels.',
);
return;
}
addToast(
'success',
`Cleanup completed — deleted ${deleted} row(s)` +
(data.sr_refresh_ok
? `; rebuilt S/R for ${data.sr_refresh_ok} ticker(s)`
: ''),
);
},
onError: (error: Error) => {
addToast('error', error.message || 'Failed to cleanup data');