def find_notifications()

in services/github-bots/LabelBotAddLabels/LabelBot.py [0:0]


    def find_notifications(self):
        """
        This method is to find comments which @mxnet-label-bot
        @:return [{"issue" : issue_id, "labels": []},...]
        """
        issues = []
        pages = self.count_pages("issues")
        for page in range(1, pages+1):
            url = 'https://api.github.com/repos/{}/{}'.format(self.repo, 'issues')
            response = requests.get(url,
                                    {'state': 'open',
                                     'base': 'master',
                                     'sort': 'created',
                                     'direction': 'desc',
                                     'page': page,
                                     'per_page': 100},
                                     auth=self.auth)
            for item in response.json():
                # limit the amount of unlabeled issues per execution
                if len(issues) >= 50:
                    break
                if not item['labels']:
                    if item['comments'] != 0:
                        labels = []
                        comments_url = "https://api.github.com/repos/{}/issues/{}/comments".format(self.repo,item['number'])
                        comments = requests.get(comments_url, auth=self.auth).json()
                        for comment in comments:
                            if "@mxnet-label-bot" in comment['body']:
                                labels += self.tokenize(comment['body'])
                                logging.debug("issue: {}, comment: {}".format(str(item['number']),comment['body']))
                        if labels != []:
                            issues.append({"issue": item['number'], "labels": labels})
        return issues