eyeonus / TradeDangerous-listener

An EDDN listener, designed to work in conjunction with the EDDBlink plugin for Trade Dangerous.
GNU Lesser General Public License v3.0
4 stars 3 forks source link

Fix items removed from stations not being updated in DB. #5

Closed eyeonus closed 6 years ago

eyeonus commented 6 years ago

Solution to problem of commodities that have been removed as a saleable item from a station not being updated as such and remaining in DB with the old data, because both EDDN and EDDB updates do [I]not[/I] include removed items: (To be implemented in the listener's message processor method): Create a Dict of the commodities list containing each of the commodities, already processed and ready for insertion. (Basically what's being done now, except that as it is now it inserts directly after processing.) --side note: Make sure the key for each entry in the Dict is the name of the commodity, so e.g. processed_item['Hydrogen Fuel'] = (demand_price = commodity['sellPrice'], ...) Loop through the item_ids keys and [code] for each key: if key in processed_item: to_insert = processed_item[key] else: to_insert = 0'd entry perform insert [/code] By 0'd entry, TD has a set of values for listings that will cause TD to auto-remove them the next time it reloads the DB, and ignore them until then. Refer to the TD documentation on CORRECTIONS to find out what it is. (Pretty sure it's just every value set to 0, including the timestamp.) --sidenote - from_live [B][I]must[/I][/B] be set to 1 when inseting a 0'd entry so that the listings exporter will include it in the live file, ensuring it gets propagated to all the clients. TD ignores from_live, so this is not a problem.