added price drops to alerts/fixed race condition where late claimed docs got their tags wiped and sent to the api without tags
This commit is contained in:
1 parent
03cc3a35cb
commit
0275f94500
2 files changed
+37
-6
No files matched your search
@@ -282,16 +282,19 @@ def extract_recorded_prices(existing_doc: dict | None) -> set[float]:
|
||||
def build_alert(monitor_name: str, document: dict, now: datetime) -> dict:
|
||||
"""Build an alert referencing a product for consumer delivery.
|
||||
|
||||
The alert carries its own copy of the document's newListing flag: the
|
||||
product doc is rewritten every cycle, so its flag flips False one cycle
|
||||
after discovery, while a discovery alert may sit in a backed-up queue
|
||||
longer than that. The alert's copy is written once and cannot rot.
|
||||
The alert carries its own copy of the document's newListing flag and
|
||||
priceBeforeDrop: the product doc is rewritten every cycle, so its flag
|
||||
flips False one cycle after discovery and its priceBeforeDrop is
|
||||
cleared by the next cycle that sees no drop, while an alert may sit in
|
||||
a backed-up queue longer than that. The alert's copies are written once
|
||||
and cannot rot.
|
||||
|
||||
Args:
|
||||
monitor_name: Monitor that produced the product, used by the
|
||||
consumer to resolve the owning collection and thresholds.
|
||||
document: Product document supplying the id, pricing for the
|
||||
priority calculation, and the stamped newListing flag.
|
||||
priority calculation, and the stamped newListing flag and
|
||||
priceBeforeDrop.
|
||||
now: Detection timestamp stored as createdAt.
|
||||
|
||||
Returns:
|
||||
@@ -306,6 +309,7 @@ def build_alert(monitor_name: str, document: dict, now: datetime) -> dict:
|
||||
"attempts": 0,
|
||||
"createdAt": now,
|
||||
"newListing": document.get("newListing", False),
|
||||
"priceBeforeDrop": document.get("priceBeforeDrop"),
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user