Skip to content

Commit

Permalink
Update EveScout integration to use new API
Browse files Browse the repository at this point in the history
  • Loading branch information
secondfry committed Dec 2, 2023
1 parent f600f3f commit 95232f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
1 change: 1 addition & 0 deletions src/shortcircuit/model/evedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class WormholeTimespan(int, Enum):


class WormholeMassspan(int, Enum):
UNKNOWN = 0
STABLE = 1
DESTAB = 2
CRITICAL = 3
Expand Down
32 changes: 13 additions & 19 deletions src/shortcircuit/model/evescout.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class EveScout:
"""
TIMEOUT = 2

def __init__(self, url: str = 'https://www.eve-scout.com/api/wormholes'):
def __init__(self, url: str = 'https://api.eve-scout.com/v2/public/signatures'):
self.eve_db = EveDb()
self.evescout_url = url

Expand All @@ -41,28 +41,22 @@ def augment_map(self, solar_map: SolarMap):
# we get some sort of response so at least something is working
connections = 0
json_response = result.json()
for row in json_response:
for connection in json_response:
connections += 1

# Retrieve signature meta data
source = row['sourceSolarSystem']['id']
dest = row['destinationSolarSystem']['id']
sig_source = row['signatureId']
code_source = row['sourceWormholeType']['name']
sig_dest = row['wormholeDestinationSignatureId']
code_dest = row['destinationWormholeType']['name']
if row['wormholeEol'] == 'stable':
wh_life = WormholeTimespan.STABLE
else:
wh_life = WormholeTimespan.CRITICAL
if row['wormholeEol'] == 'stable':
wh_mass = WormholeMassspan.STABLE
elif row['wormholeEol'] == 'destab':
wh_mass = WormholeMassspan.DESTAB
else:
wh_mass = WormholeMassspan.CRITICAL
source = connection['in_system_id']
sig_source = connection['in_signature']
code_source = 'K162' if connection['wh_exits_outward'] else connection['wh_type']
dest = connection['out_system_id']
sig_dest = connection['out_signature']
code_dest = connection['wh_type'] if connection['wh_exits_outward'] else 'K162'

wh_life = WormholeTimespan.STABLE if connection['remaining_hours'] >= 4 else WormholeTimespan.CRITICAL
wh_mass = WormholeMassspan.UNKNOWN

# Compute time elapsed from this moment to when the signature was updated
last_modified = datetime.strptime(row['updatedAt'][:-5], "%Y-%m-%dT%H:%M:%S")
last_modified = datetime.strptime(connection['updated_at'], "%Y-%m-%dT%H:%M:%S.000Z")
delta = datetime.utcnow() - last_modified
time_elapsed = round(delta.total_seconds() / 3600.0, 1)

Expand Down

0 comments on commit 95232f6

Please sign in to comment.