def _process_awakenings(self, db): logger.warning('loading awakenings') for m in self.data.ownable_cards: items = Awakening.from_csm(m) for item in items: try: db.insert_or_update(item) except: human_fix_logger.fatal( 'Failed to insert item (probably new awakening): %s', pad_util.json_string_dump(item, pretty=True))
def _process_awakenings(self, db): logger.info('loading awakenings') for m in self.data.ownable_cards: items = Awakening.from_csm(m) for item in items: try: db.insert_or_update(item) except (KeyboardInterrupt, SystemExit): raise except: human_fix_logger.fatal('Failed to insert item (probably new awakening): %s', pad_util.json_string_dump(item, pretty=True)) sql = 'SELECT COUNT(*) FROM awakenings WHERE monster_id = {}'.format(m.monster_id) stored_awakening_count = db.get_single_value(sql, op=int) if len(items) < stored_awakening_count: human_fix_logger.error('Incorrect awakening count for %s, got %s wanted %s', m.monster_id, stored_awakening_count, len(items))
def _process_awakenings(self, db): logger.info('loading awakenings') for m in self.data.ownable_cards: items = Awakening.from_csm(m) for item in items: try: db.insert_or_update(item) except (KeyboardInterrupt, SystemExit): raise except Exception: human_fix_logger.fatal( 'Failed to insert item (probably new awakening): %s', pad_util.json_string_dump(item, pretty=True)) sql = f'DELETE FROM {Awakening.TABLE} WHERE monster_id = {m.monster_id} AND order_idx >= {len(items)}' deleted_awos = db.update_item(sql) if deleted_awos: logger.info( f"Deleted {deleted_awos} unused awakenings from monster {m.monster_id}" )