Skip to content

Commit

Permalink
optimize fetching order details
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleGoogle committed Jul 21, 2019
1 parent 1a8a195 commit f8dab9d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
20 changes: 15 additions & 5 deletions src/plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import sys
import time
import asyncio
import os
import json
import logging
Expand Down Expand Up @@ -58,12 +60,20 @@ def is_game(sub):

games = {}
gamekeys = await self._api.get_gamekeys()
for gamekey in gamekeys:
details = await self._api.get_order_details(gamekey)
logging.info(f'Parsing details of order {gamekey}:\n{json.dumps(details, indent=4)}')
requests = [self._api.get_order_details(x) for x in gamekeys]

logging.info(f'Fetching info about {len(requests)} orders started...')
all_games_details = await asyncio.gather(*requests)
logging.info('Fetching info finished')

for details in all_games_details:
for sub in details['subproducts']:
if is_game(sub):
games[sub['machine_name']] = HumbleGame(sub)
try:
if is_game(sub):
games[sub['machine_name']] = HumbleGame(sub)
except Exception as e:
logging.error(f'Error while parsing subproduct {sub}: {repr(e)}')
continue

self._games = games
return [g.in_galaxy_format() for g in games.values()]
Expand Down
2 changes: 1 addition & 1 deletion src/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.1"
__version__ = "0.1.2"
2 changes: 1 addition & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import asyncio


CREDENTIALS_FILE = "credentials-other"
CREDENTIALS_FILE = "credentials.data"


if __name__ == "__main__":
Expand Down

0 comments on commit f8dab9d

Please sign in to comment.