fix: harden Structural S/R after OHLCV writes and surface cleanup failures
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:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user