From 6932fdc88322b60e1ec1da7474edf0caab5e956d Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sat, 11 Jul 2020 18:57:04 +0100 Subject: [PATCH 1/2] EDDB: Use CAPI for system_address/station_marketid only if not already set See issue #586 - a user had incorrect system_address set, but only sometimes. This could possibly be due to CAPI errors/lag, so only use it as the source when the values aren't yet set. Otherwise Journal should always have provided the correct value in a timely manner. --- plugins/eddb.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/eddb.py b/plugins/eddb.py index 9c17b497..f0e31ba6 100644 --- a/plugins/eddb.py +++ b/plugins/eddb.py @@ -69,10 +69,16 @@ def journal_entry(cmdr, is_beta, system, station, entry, state): def cmdr_data(data, is_beta): if config.get('system_provider') == 'eddb': - this.system_address = data['lastSystem']['id'] or this.system_address - this.system_link['url'] = system_url(this.system_address) # Override standard URL function + # Only fill in system_address from CAPI if it's not set yet + # This is to avoid CAPI lagging causing incorrect value + if not this.system_address: + this.system_address = data['lastSystem']['id'] + this.system_link['url'] = system_url(this.system_address) # Override standard URL function if config.get('station_provider') == 'eddb': - this.station_marketid = data['commander']['docked'] and data['lastStarport']['id'] - this.station_link['text'] = data['commander']['docked'] and data['lastStarport']['name'] or (data['lastStarport']['name'] and data['lastStarport']['name'] != "" and STATION_UNDOCKED or '') - this.station_link.update_idletasks() + # Only use CAPI value if not yet set + # This is to avoid CAPI lagging causing incorrect value + if not this.station_marketid: + this.station_marketid = data['commander']['docked'] and data['lastStarport']['id'] + this.station_link['text'] = data['commander']['docked'] and data['lastStarport']['name'] or (data['lastStarport']['name'] and data['lastStarport']['name'] != "" and STATION_UNDOCKED or '') + this.station_link.update_idletasks() From 317a0f6b6313ce69324efd8432da6ff726e4605d Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sat, 11 Jul 2020 19:47:30 +0100 Subject: [PATCH 2/2] EDDB is default station provider, do station_marketid as needed We need a better way to do provider defaults. Heck, settings defaults period. Let's assume we'll put in place a "standard" config file once we move to one. --- plugins/eddb.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/eddb.py b/plugins/eddb.py index f0e31ba6..28e88b6e 100644 --- a/plugins/eddb.py +++ b/plugins/eddb.py @@ -75,7 +75,8 @@ def cmdr_data(data, is_beta): this.system_address = data['lastSystem']['id'] this.system_link['url'] = system_url(this.system_address) # Override standard URL function - if config.get('station_provider') == 'eddb': + # 'eddb' is also the *default* Station provider + if not config.get('station_provider') or config.get('station_provider') == 'eddb': # Only use CAPI value if not yet set # This is to avoid CAPI lagging causing incorrect value if not this.station_marketid: