def get_attendees(self): Logger.info('Getting Attendees for Phase: {0}:{1}'.format( self.id, self.name)) phase_groups = self.get_phase_groups() attendees = flatten( [phase_group.get_attendees() for phase_group in phase_groups]) return attendees
def get_entrants(self): Logger.info('Getting Entrants for Phase: {0}:{1}'.format( self.id, self.name)) phase_groups = self.get_phase_groups() entrants = flatten( [phase_group.get_entrants() for phase_group in phase_groups]) return entrants
def paginated_query(query_string: str, variables: dict) -> list: Logger.debug('NetworkInterface.paginated_query: creating query object') query = QueryFactory.create(query_string, variables) Logger.debug( 'NetworkInterface.paginated_query: created query {}'.format(query)) Logger.debug( 'NetworkInterface.paginated_query: sending query to queue') QueryQueue.get_instance().add(query) results = [] initial_result = NetworkInterface.execute_query(query) base_data = NetworkInterface.parse_paginated_result(initial_result) results.append(base_data['nodes']) total_pages = base_data['pageInfo']['totalPages'] for i in range(2, total_pages + 1, 1): variables['page'] = i current_query = QueryFactory.create(query_string, variables) current_result = NetworkInterface.execute_query(current_query) current_base_data = NetworkInterface.parse_paginated_result( current_result) results.append(current_base_data['nodes']) return flatten(results)
def get_attendees(self): assert (self.id is not None), 'phase group id cannot be None when calling get_attendees' Logger.info('Getting Attendees for phase group: {0}:{1}'.format(self.id, self.display_identifier)) data = NI.paginated_query(queries.phase_group_attendees, {'id': self.id}) participants = flatten([entrant_data['entrant']['participants'] for entrant_data in data]) attendees = [Attendee.parse(participant_data) for participant_data in participants] return attendees
def get_attendees(self): assert (self.id is not None ), "tournament id cannot be None if calling get_attendees" Logger.info('Getting Attendees for Tournament: {0}:{1}'.format( self.id, self.name)) phase_groups = self.get_phase_groups() attendees = flatten( [phase_group.get_attendees() for phase_group in phase_groups]) return attendees
def get_sets(self): assert (self.id is not None), 'event id cannot be None if calling get_sets' Logger.info('Getting Sets for Event: {0}:{1}'.format( self.id, self.name)) phase_groups = self.get_phase_groups() sets = flatten( [phase_group.get_sets() for phase_group in phase_groups]) return sets
def get_entrants(self): assert (self.id is not None ), "tournament id cannot be None if calling get_entrants" Logger.info('Getting Entrants for Tournament: {0}:{1}'.format( self.id, self.name)) Logger.warning('Aggregate queries ') phase_groups = self.get_phase_groups() entrants = flatten( [phase_group.get_entrants() for phase_group in phase_groups]) return entrants
def get_phase_groups(self): assert (self.id is not None ), "phase id cannot be None when calling get_phase_groups" Logger.info('Getting Phase Groups for Phase: {0}:{1}'.format( self.id, self.name)) data = NI.paginated_query(queries.phase_phase_groups, {'id': self.id}) [validate_data(phase_data) for phase_data in data] # Schema Validation [Phase.validate_data(element['data'], self.id) for element in data] phase_data = [phase_data['data']['phase'] for phase_data in data] [PhaseGroup.validate_data(element, self.id) for element in phase_data] phase_group_data = flatten( [element['phaseGroups'] for element in phase_data]) return [ PhaseGroup.parse(phase_group) for phase_group in phase_group_data ]