Fix, add _id field to results for debugging

This commit is contained in:
Jylpah committed 2020-11-26 01:35:24 +02:00
1 parent 6ceffc3915
commit 19c0e3857e
1 file changed
+10 -4
+10 -4
View File
@@ -828,7 +828,10 @@ class BattleCategory():
@classmethod @classmethod
def get_result_fields_ratio(cls) -> list: def get_result_fields_ratio(cls, all: bool = False) -> list:
if all:
return cls._result_ratios.keys()
else:
return cls.result_fields_ratio return cls.result_fields_ratio
@@ -868,6 +871,8 @@ class BattleCategory():
value = result[cls._result_ratios[ratio][0]] value = result[cls._result_ratios[ratio][0]]
divider = result[cls._result_ratios[ratio][1]] divider = result[cls._result_ratios[ratio][1]]
if divider != 0: if divider != 0:
if value == None:
value = 0
return value / divider return value / divider
else: else:
if value == 0: if value == 0:
@@ -875,7 +880,7 @@ class BattleCategory():
else: else:
return float('Inf') return float('Inf')
except Exception as err: except Exception as err:
bu.error(exception=err) bu.error('Replay _id=' + result['_id'] , exception=err)
return None return None
@@ -1939,7 +1944,7 @@ async def mk_replayQ(queue : asyncio.Queue, args : argparse.Namespace, db : moto
bu.debug('Reading replays...') bu.debug('Reading replays...')
async for replay_json in cursor: async for replay_json in cursor:
_id = replay_json['_id'] _id = replay_json['_id']
del(replay_json['_id']) #del(replay_json['_id'])
await queue.put(await mk_readerQ_item(replay_json, 'DB: _id = ' + _id)) await queue.put(await mk_readerQ_item(replay_json, 'DB: _id = ' + _id))
Nreplays += 1 Nreplays += 1
bu.debug('All the matching replays have been read from the DB') bu.debug('All the matching replays have been read from the DB')
@@ -2054,6 +2059,7 @@ async def read_replay_JSON(replay_json: dict, args : argparse.Namespace) -> dict
bu.debug('Invalid replay') bu.debug('Invalid replay')
return None return None
result['_id'] = replay_json['_id']
result['battle_start_timestamp'] = int(replay_json['data']['summary']['battle_start_timestamp']) result['battle_start_timestamp'] = int(replay_json['data']['summary']['battle_start_timestamp'])
# TBD... # TBD...
protagonist = int(replay_json['data']['summary']['protagonist']) protagonist = int(replay_json['data']['summary']['protagonist'])
@@ -2159,7 +2165,7 @@ async def read_replay_JSON(replay_json: dict, args : argparse.Namespace) -> dict
# platoon buddy removed from stats # platoon buddy removed from stats
result['allies'].remove(get_stat_id(tmp_account_id, tmp_tank_id, tmp_battletime)) result['allies'].remove(get_stat_id(tmp_account_id, tmp_tank_id, tmp_battletime))
break break
for ratio in BattleCategory.get_result_fields_ratio(): for ratio in BattleCategory.get_result_fields_ratio(all=True):
result[ratio] = BattleCategory.calc_ratio(ratio, result) result[ratio] = BattleCategory.calc_ratio(ratio, result)
result['time_alive%'] = result['time_alive'] / btl_duration result['time_alive%'] = result['time_alive'] / btl_duration