示例#1
0
def github_issues():
    if settings.DEBUG:
        return
    from git.utils import get_issues, get_user
    repos = []

    for org in ['bitcoin', 'gitcoinco', 'ethereum']:
        for repo in get_user(org, '/repos'):
            repos.append((org, repo['name']))

    for org, repo in repos:
        issues = []
        cont = True
        page = 1
        while cont:
            new_issues = get_issues(org, repo, page, 'all')
            issues = issues + new_issues
            page += 1
            cont = len(new_issues)

        val = len(issues)
        key = f"github_issues_{org}_{repo}"
        try:
            Stat.objects.create(
                created_on=timezone.now(),
                key=key,
                val=(val),
            )
        except Exception:
            pass
        if not val:
            break
    def handle(self, *args, **options):

        known_repos = [('JGcarv', 'ethereum-bounty-hunters')]

        for owner, repo in known_repos:
            issues = get_issues(owner, repo)
            for bounty in issues:
                payout_str = ''
                try:
                    ExternalBounty.objects.get_or_create(
                        action_url=bounty['url'],
                        active=True,
                        description=bounty['body'],
                        source_project=repo,
                        amount=None,
                        amount_denomination='',
                        tags=[repo],
                        title=bounty['title'],
                        payout_str=payout_str,
                    )
                except Exception as e:
                    print(e)