Initial implementation of custom price triggers

- likely to have some bugs, but this is good enough for a preview release.
This commit is contained in:
2025-11-06 02:46:03 -08:00
parent 19eb0a4e24
commit ed79f4b65c
8 changed files with 197 additions and 58 deletions

View File

@@ -57,6 +57,16 @@ class HistoryManager:
await history.add_price(item)
self._history[flavor][region] = history
async def load_custom_alerts(self, custom_alerts: List[Alert]):
"""Load custom price alerts and initialize their triggers with historical data."""
for alert in custom_alerts:
history = self._history[alert.flavor][alert.region]
# This will create the trigger on-demand via find_update_trigger_from_alert
trigger = await history.find_update_trigger_from_alert(alert)
# Process all historical data through this trigger to initialize its state
for datum in history.history:
trigger.check_and_update(datum, history.history)
async def update_data(self, flavor: Flavor, region: Region) -> List[Alert]:
history = self._history[flavor][region]
current_price_data = await self._tdb.current(flavor)