Ticket Alert Mechanism - Jackiebibili/ticket_tracker_api GitHub Wiki
Precondition
- Follow the Ticket Storage design at wiki page.
Design
- Alert handling is asynchronous action and is triggered when updating the
best_available_seats
andbest_history_seats
collections. A queue is constructed to schedule the alert handlers.
Algorithms
Periodic task
- Let
A
be the list of current best available seats andB
the list of new best available seats. - Query list
A
andB
by scraping_id from the database. - Compute
C := A-B
which is the seats based on the comparator should check for (sec, row?, seat?, price). - Compute
D := B-A
which is the new seats. - Remove
C
frombest_available_seats
and insertD
tobest_available_seats
. - Save
C
tobest_history_seats
. - Use
D
to invoke a handler to analyze them against thebest_history_seats
asynchronously.
Async task
- Query the collection
best_history_seats
with some filter. - Find the percentile of the seat based on some criteria (e.g. rank or price).
- If found the exact same seat based on (sec, row?, seat?), get the history price(s) of the seat.
- Alert the user based on alert conditions
Metrics
Percent of change from min/max price to new price
Calculation
- % change = (new_price - min) / (max-min) or (max - new_price) / (max-min)
best_history_seats
Percentile of the new price in Calculation
- percentile = new_price_rank / total_count_of_history_seats
Example
- If there are
r1
number of history tickets whose prices <= new price andtotal
the total count of history tickets, then the percentile =r1/total
.
Thresholds
If the two thresholds are low, the alerting is less sensitive, meaning the tracker will be less frequent to send price alerts to users.
Percent of change from min/max price to new price
= 0.5
Example
min = $100, max = $200, the threshold will be met when the price is <= $150.
best_history_seats
Percentile of the new price in history prices in = 0.5 (i.e. the median)
Alert Actions and Conditions
Rank Increases - Similar Prices
Precondition:
- In comparison to the new seat, tickets in
best_history_seats
that shared a similar price (>= new ticket price) and have a lower rank have been found.
Main Success Scenario:
- Alert user of a
rank increase
with new and old prices and the percentile.
Rank Decreases - Similar Prices
Precondition:
- In comparison to the new seat, tickets in
best_history_seats
that shared a similar price (<= new ticket price) and have a higher rank have been found.
Main Success Scenario:
- Alert user of a
rank drop
with new and old prices and the percentile.
Price Decreases - Similar Ranks
Precondition:
- In comparison to the new seat, tickets in
best_history_seats
that shared a similar rank (<= new ticket rank) and have a higher price have been found. - i.e. Found a lower price of seats than those of the same viewing experience (rank).
Main Success Scenario:
- Alert user of a
price drop
with alternative seat (new) price, old prices in the neighborhood of the spot located from querying, and the percentile.
Price Increases - Similar Ranks
Precondition:
- In comparison to the new seat, tickets in
best_history_seats
that shared a similar rank (>= new ticket rank) and have a lower price have been found. - i.e. Found a higher price of seats than those of the same viewing experience (rank).
Main Success Scenario:
- Alert user of a
price increase
with alternative seat (new) price, old prices in the neighborhood of the spot located from querying, and the percentile.