def __process_stats(self, stats, client_id: int, last_processed_timestamp: float): logger.info('Submitting stats for origin {}', str(client_id)) data_send_stats = [] data_send_location = [] data_send_stats.append( PlayerStats.stats_complete_parser(client_id, stats, last_processed_timestamp)) data_send_location.append( PlayerStats.stats_location_parser(client_id, stats, last_processed_timestamp)) self.__db_wrapper.submit_stats_complete(data_send_stats) self.__db_wrapper.submit_stats_locations(data_send_location) if self.__application_args.game_stats_raw: data_send_location_raw = PlayerStats.stats_location_raw_parser( client_id, stats, last_processed_timestamp) data_send_detection_raw = PlayerStats.stats_detection_raw_parser( client_id, stats, last_processed_timestamp) self.__db_wrapper.submit_stats_locations_raw( data_send_location_raw) self.__db_wrapper.submit_stats_detections_raw( data_send_detection_raw) self.__db_wrapper.cleanup_statistics()
def __init__(self, mapping_manager: MappingManager, db_stats_submit: DbStatsSubmit): self.__mapping = {} self.__playerstats: Dict[str, PlayerStats] = {} self.__mapping_mutex = Lock() self.__mapping_manager: MappingManager = mapping_manager self.__injected = {} self.__last_cellsid = {} self.__last_possibly_moved = {} self.__application_args = args self._db_stats_submit: DbStatsSubmit = db_stats_submit self.__playerstats_db_update_stop: Event = Event() self.__playerstats_db_update_queue: Queue = Queue() self.__playerstats_db_update_mutex: Lock = Lock() self.__playerstats_db_update_consumer: Thread = Thread( name="playerstats_update_consumer", target=self.__internal_playerstats_db_update_consumer) if self.__mapping_manager is not None: for origin in self.__mapping_manager.get_all_devicemappings().keys( ): self.__mapping[origin] = {} self.__playerstats[origin] = PlayerStats( origin, self.__application_args, self) self.__playerstats[origin].open_player_stats() self.__playerstats_db_update_consumer.daemon = True self.__playerstats_db_update_consumer.start()
def __add_new_device(self, origin): self.__mapping[origin] = {} self.__playerstats[origin] = PlayerStats(origin, self.__application_args, self) self.__playerstats[origin].open_player_stats()