def do_scan(scanner, games_col, accum_stats, max_games): """ Use scanner to accumulate stats from games_col into accum_stats . scanner: incremental_scanner.Scanner to use for traversal. games_col: Mongo collection to scan. accum_stats: DeckBuyStats instance to store results. """ accum_buy_stats(analysis_util.games_stream(scanner, games_col), accum_stats, max_games=max_games)
def main(): args = utils.incremental_max_parser().parse_args() c = pymongo.Connection() db = c.test scanner = incremental_scanner.IncrementalScanner('analyze2', db) if not args.incremental: scanner.reset() for collection_name, _ in event_detectors: db[collection_name].drop() print scanner.status_msg() games_stream = analysis_util.games_stream(scanner, c.test.games) accumulator = EventAccumulator() accumulate_card_stats(games_stream, accumulator, args.max_games) print 'saving to database' accumulator.update_db(db) scanner.save() print scanner.status_msg()
def main(args): db = utils.get_mongo_database() scanner = incremental_scanner.IncrementalScanner('analyze2', db) if not args.incremental: log.warning('resetting scanner and db') scanner.reset() for collection_name, _ in event_detectors: db[collection_name].drop() log.info("Starting run: %s", scanner.status_msg()) games_stream = analysis_util.games_stream(scanner, db.games) accumulator = EventAccumulator() accumulate_card_stats(games_stream, accumulator, args.max_games) log.info('saving to database') log.debug('saving accumulated stats') accumulator.update_db(db) log.info('saving the game scanner state') scanner.save() log.info("Ending run: %s", scanner.status_msg())