Make the info panel show the correct last alerting
Before, it was checking against the moved pointer, which could cause inaccurate
This commit is contained in:
parent
ac5d794df1
commit
50f65abced
@ -10,6 +10,7 @@ class UpdateTrigger:
|
||||
def __init__(self, alert: Alert):
|
||||
self._alert : Alert = alert
|
||||
self._last_trigger : Tuple[datetime.datetime, int] | None = None
|
||||
self._last_alerting: Tuple[datetime.datetime, int] | None = None
|
||||
self._squelched : bool = False
|
||||
|
||||
@property
|
||||
@ -20,6 +21,9 @@ class UpdateTrigger:
|
||||
def last_trigger(self) -> Tuple[datetime.datetime, int] | None:
|
||||
return self._last_trigger
|
||||
|
||||
def last_alerting(self) -> Tuple[datetime.datetime, int] | None:
|
||||
return self._last_alerting
|
||||
|
||||
def _find_next_trigger(self, comparison_operator: operator, starting_point: datetime.datetime, history: List[Tuple[datetime.datetime, int]]):
|
||||
candidate_datum : Tuple[datetime.datetime, int] | None = None
|
||||
for datum in history:
|
||||
@ -78,6 +82,7 @@ class UpdateTrigger:
|
||||
if new_datum[0] > now - time_range:
|
||||
if self._last_trigger is None:
|
||||
self._last_trigger = new_datum
|
||||
self._last_alerting = new_datum
|
||||
return True
|
||||
|
||||
# If the self._last_trigger falls out of scope of the alert, find the next thing that would have triggered
|
||||
@ -88,6 +93,7 @@ class UpdateTrigger:
|
||||
|
||||
if comparison_operator(new_datum[1], self._last_trigger[1]):
|
||||
self._last_trigger = new_datum
|
||||
self._last_alerting = new_datum
|
||||
was_squelched = self._squelched
|
||||
self._squelched = True
|
||||
return not was_squelched
|
||||
|
@ -289,8 +289,8 @@ class Tracker(Extension):
|
||||
history = await self._history_manager.get_history(alert.flavor, alert.region)
|
||||
trigger = await history.find_update_trigger_from_alert(alert)
|
||||
if trigger.last_trigger is not None:
|
||||
alert_str = (f"Last Alerting Price Value: {format(trigger.last_trigger[1], ",")}\n"
|
||||
f"Last Alerting Time: {trigger.last_trigger[0].strftime('%Y-%m-%d %H:%M:%S UTC')}\n")
|
||||
alert_str = (f"Last Alerting Price Value: {format(trigger.last_alerting()[1], ",")}\n"
|
||||
f"Last Alerting Time: {trigger.last_alerting()[0].strftime('%Y-%m-%d %H:%M:%S UTC')}\n")
|
||||
else:
|
||||
alert_str = "You should only be seeing this if the bot has not finished importing history at startup."
|
||||
fields.append(
|
||||
|
Loading…
Reference in New Issue
Block a user