(self)
return counts
Gather statistics for each category in the Trello board.
Gather statistics for each category in the Trello board.
Gather statistics for each category in the Trello board .
def count_by_columns(self):
        """
        Gather statistics for each category in the Trello board.

        """
        map_label = {v: k for k, v in self.label_map.items()}
        map_team_list = {v: k for k, v in self.team_list_map.items()}

        counts = {
            k: {'Total': 0, 'Inbox': 0, 'In Progress': 0, 'Issues Found': 0, 'Awaiting Build': 0, 'Done': 0}
            for k in map_label.values()
        }

        cards = requests.get(self.BOARD_ENDPOINT, params=self.auth)
        for card in cards.json():
            labels = card.get('labels', [])
            if self.skip_card(labels):
                continue
            team_found = False
            for label in labels:
                if label['name'] in self.label_map:
                    team = label['name']
                    id_list = card['idList']
                    if id_list in map_team_list:
                        counts[team]['Total'] += 1
                        counts[team]['Inbox'] += 1
                    elif id_list in self.progress_columns:
                        counts[team]['Total'] += 1
                        counts[team][self.progress_columns[id_list]] += 1
                    team_found = True
            if not team_found and len(labels) >= 1 and card['idList'] != self.RC_BUILDS_COLUMN:
                label_names = list(map(lambda label: label['name'], labels))
                raise Exception(
                    f'{card["url"]}: Cannot find a team from the labels {label_names}. Was a label updated?'
                )
        return counts
def count_by_columns ( self ) : map_label = { v : k for k , v in self . label_map . items ( ) } map_team_list = { v : k for k , v in self . team_list_map . items ( ) } counts = { k : { 'Total' : 0 , 'Inbox' : 0 , 'In Progress' : 0 , 'Issues Found' : 0 , 'Awaiting Build' : 0 , 'Done' : 0 } for k in map_label . values ( ) } cards = requests . get ( self . BOARD_ENDPOINT , params = self . auth ) for card in cards . json ( ) : labels = card . get ( 'labels' , [ ] ) if self . skip_card ( labels ) : continue team_found = False for label in labels : if label [ 'name' ] in self . label_map : team = label [ 'name' ] id_list = card [ 'idList' ] if id_list in map_team_list : counts [ team ] [ 'Total' ] += 1 counts [ team ] [ 'Inbox' ] += 1 elif id_list in self . progress_columns : counts [ team ] [ 'Total' ] += 1 counts [ team ] [ self . progress_columns [ id_list ] ] += 1 team_found = True if not team_found and len ( labels ) >= 1 and card [ 'idList' ] != self . RC_BUILDS_COLUMN : label_names = list ( map ( lambda label : label [ 'name' ] , labels ) ) raise Exception ( f'{card["url"]}: Cannot find a team from the labels {label_names}. Was a label updated?' ) return counts