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.
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.