mirror of https://github.com/ghostfolio/ghostfolio
Browse Source
Replace delete-then-fetch pattern with atomic transaction to prevent data loss when manually gathering historical market data fails. Previously, when triggering "Gather Historical Market Data" from the Admin panel, the system would immediately delete all existing market data before queueing the fetch job. If the external data provider was down or returned an error, the asset would be left with no historical data and the original data was permanently lost. Changes: - Add `replaceAllForSymbol()` method to MarketDataService that performs delete and insert within a Prisma transaction - Remove upfront `deleteMany()` call from `gatherSymbol()` method - Add `replaceExistingData` flag to DataGatheringItem interface to distinguish manual refresh from scheduled updates - Update data gathering processor to use atomic replace only for manual operations while keeping normal upsert behavior for scheduled updates - Remove unused MarketDataService dependency from DataGatheringService The atomic transaction ensures that if the fetch operation fails, the original market data remains untouched. Regular scheduled data gathering continues to use upsert operations and is unaffected by this change.pull/5858/head
5 changed files with 66 additions and 10 deletions
Loading…
Reference in new issue