Remian103 / lolskin-price-tracker

A web app for tracking LoL skin price
3 stars 1 forks source link

Update 'price' and 'sale_price 'in 'skins' table properly based on 'price_history' table #30

Closed jiyolla closed 3 years ago

jiyolla commented 3 years ago

Currently, all skins have price and sale_price set to 0. When updating price_history, corresponding skin's price and sale_price also have to be updated.

jiyolla commented 3 years ago

It's a bad idea to update the skin table whenever a call is made. The best timing for the update might be when the new price_history record is added.(i.e is when the udpate_price_history.py works). But putting this logic in update_price_history or the instance where the league client is running seems inappropriate since this function itself is unreliable yet.

The best one seems to use TRIGGER sql statement supported by PostgreSQL, which is unfortunately unsupported by SQLAlchemy's orm but available in through custom DDL.

jiyolla commented 3 years ago

Implemented in dev.

jiyolla commented 3 years ago

It's originally implemented in bcd1a5b5cf2db8e86311d0c7fc513d1b84cf2714 But later reverted. Now there's a new field called 'last_price_history' which has an entire price history that is the most up to date. Or it's null if there's none.