Example #1
0
def index(request):
    if not request.GET:
        context = {
            'title': "Project list",
            'project_list': Project.objects.order_by('name').all()
        }
        return render(request, 'index.html', context)

    project, repos = proj_repo.proj_repo(request)

    if repos != None:
        before = time.time()

        current_user = None
        if 'login' in request.GET:
            current_user = request.GET['login']

        prf = PrFetcher(settings.TOP_LEVEL_URL, settings.ORG, repos,
                        current_user)
        context = {
            "title": project,
            "projects": prf.get_prs(),
            "feedback_ok": settings.FEEDBACK_OK['name'],
            "feedback_weak": settings.FEEDBACK_WEAK['name'],
            "feedback_ko": settings.FEEDBACK_KO['name']
        }

        after = time.time()
        logger.debug("page generated in %s sec" % (after - before))
        return render(request, 'pr.html', context)
    else:
        return HttpResponse("No projects found\n", status=404)
Example #2
0
def index(request):
    if not request.GET:
        context = {'title': "Project list",
                   'project_list' : Project.objects.order_by('name').all()}
        return render(request, 'index.html', context)

    project, repos = proj_repo.proj_repo(request)

    if repos != None:
        before = time.time()

        current_user = None
        if 'login' in request.GET:
            current_user = request.GET['login']

        prf = PrFetcher(settings.TOP_LEVEL_URL, settings.ORG, repos, current_user)
        context = {"title" : project,
                   "projects" : prf.get_prs(),
                   "feedback_ok" : settings.FEEDBACK_OK['name'],
                   "feedback_weak" : settings.FEEDBACK_WEAK['name'],
                   "feedback_ko" : settings.FEEDBACK_KO['name']}

        after = time.time()
        logger.debug("page generated in %s sec" % (after - before))
        return render(request, 'pr.html', context)
    else:
        return HttpResponse("No projects found\n", status=404)
Example #3
0
def index(request):
    if not request.GET:
        context = {'title': "Project list",
                   'project_list' : Project.objects.order_by('name').all()}
        return render(request, 'index.html', context)

    project, repos = proj_repo.proj_repo(request)
    columns = Project.objects.get(name=project).columns.all()
    column_names = []
    for column in columns:
        column_names.append(column.name)

    if repos:
        before = time.time()

        current_user = None
        if 'login' in request.GET:
            current_user = request.GET['login']

        # We could optimize PrFetch by adjusting the number of request with the displayed columns.
        # However, this will make testing more difficult and code more complex.
        prf = PrFetcher(settings.TOP_LEVEL_URL, settings.ORG, repos, current_user)
        context = {"title" : project,
                   "projects" : prf.get_prs(),
                   "columns" : column_names}

        after = time.time()
        logger.debug("page generated in %s sec" % (after - before))
        return render(request, 'pr.html', context)
    else:
        return HttpResponse("No projects found\n", status=404)
Example #4
0
def index(request):
    if not request.GET:
        context = {'title': "Project list",
                   'project_list' : sorted(settings.PROJECTS_REPOS.keys())}
        return render(request, 'index.html', context)

    project, repos = proj_repo.proj_repo(request)

    if repos != None:
        before = time.time()

        current_user = None
        if 'login' in request.GET:
            current_user = request.GET['login']

        prf = PrFetcher(settings.TOP_LEVEL_URL, settings.ORG, repos, current_user)
        context = {"title" : "%s PR list" % project,
                   "projects" : prf.get_prs(),
                   "feedback_ok" : settings.FEEDBACK_OK['name'],
                   "feedback_weak" : settings.FEEDBACK_WEAK['name'],
                   "feedback_ko" : settings.FEEDBACK_KO['name']}

        after = time.time()
        print(after - before)
        return render(request, 'pr.html', context)
    else:
        return HttpResponse("No projects found\n", status=404)
Example #5
0
def index(request):
    if not request.GET:
        context = {
            'title': "Project list",
            'project_list': settings.PROJECTS_REPOS.keys()
        }
        return render(request, 'index.html', context)

    project, repos = proj_repo.proj_repo(request)

    if repos != None:
        before = time.time()

        current_user = None
        if 'login' in request.GET:
            current_user = request.GET['login']

        prf = PrFetcher(settings.TOP_LEVEL_URL, settings.ORG, repos,
                        current_user)
        context = {
            "title": "%s PR list" % project,
            "project_list": prf.get_prs(),
            "feedback_ok": settings.FEEDBACK_OK['name'],
            "feedback_weak": settings.FEEDBACK_WEAK['name'],
            "feedback_ko": settings.FEEDBACK_KO['name']
        }

        after = time.time()
        print(after - before)
        return render(request, 'pr.html', context)
    else:
        return HttpResponse("No projects found\n", status=404)
Example #6
0
def slack(url, org, weburl, repos, slackurl, channel):
    """ Celery task, use github api and send result to slack
    """
    prf = PrFetcher(url, org, repos, None)
    projects = prf.get_prs()
    nb_proj = len(projects)
    total_pr = 0
    for name in projects:
        nb_pr = len(projects[name])
        total_pr += nb_pr

    txt = """Hey, we have %d PR in %d project(s) (<%s|web version>)
""" % (total_pr, nb_proj, weburl)

    if total_pr > 0:
        txt += "\n"
        for name in projects:
            txt += "*%s*\n" % name
            for pr in projects[name]:
                txt += "<%s|%s> -" % (pr.url, pr.title)
                if pr.milestone:
                    txt += " *%s* -" % (pr.milestone)
                for label in pr.labels:
                    txt += " *%s* -" % (label['name'])
                txt += " %s review: %d" % (pr.user, pr.nbreview)
                if pr.feedback_ko > 0:
                    txt += " %s" % (settings.FEEDBACK_KO['keyword'])
                elif pr.feedback_ok > 0:
                    txt += " %s: *%d*" % \
                        (settings.FEEDBACK_OK['keyword'], pr.feedback_ok)
                elif pr.feedback_weak > 0:
                    txt += " %s: %d" % \
                        (settings.FEEDBACK_WEAK['keyword'], pr.feedback_weak)

                txt += "\n"

    payload = {
        "channel": channel,
        "username": "******",
        "text": txt,
        "icon_emoji": ":y:"
    }

    urllib.request.urlopen(slackurl, json.dumps(payload).encode('utf-8'))
Example #7
0
def slack(url, org, weburl, repos, slackurl, channel):
    """ Celery task, use github api and send result to slack
    """
    prf = PrFetcher(url, org, repos, None)
    projects = prf.get_prs()
    nb_proj = len(projects)
    total_pr = 0
    for name in projects:
        nb_pr = len(projects[name])
        total_pr += nb_pr

    txt = """Hey, we have %d PR in %d project(s) (<%s|web version>)
""" % (total_pr, nb_proj, weburl)

    if total_pr > 0:
        txt += "\n"
        for name in projects:
            txt += "*%s*\n" % name
            for pr in projects[name]:
                txt += "<%s|%s> -" % (pr.url, pr.title)
                if pr.milestone:
                    txt += " *%s* -" % (pr.milestone)
                for label in pr.labels:
                    txt += " *%s* -" % (label['name'])
                txt += " %s review:%d %s:%d %s:%d" % \
                       (pr.user, pr.nbreview,
                        settings.FEEDBACK_OK['keyword'], pr.feedback_ok,
                        settings.FEEDBACK_WEAK['keyword'], pr.feedback_weak)
                if pr.feedback_ko > 0:
                    txt += " %s" % (settings.FEEDBACK_KO['keyword'])
                txt += "\n"



    payload = {"channel": channel,
               "username": "******",
               "text": txt,
               "icon_emoji": ":y:"}

    urllib.request.urlopen(slackurl, json.dumps(payload).encode('utf-8'))
Example #8
0
def index(request):
    if not request.GET:
        context = {
            'title': "Project list",
            'project_list': Project.objects.order_by('name').all()
        }
        return render(request, 'index.html', context)

    project, repos = proj_repo.proj_repo(request)
    columns = Project.objects.get(name=project).columns.all()
    column_names = []
    for column in columns:
        column_names.append(column.name)

    if repos:
        before = time.time()

        current_user = None
        if 'login' in request.GET:
            current_user = request.GET['login']

        # We could optimize PrFetch by adjusting the number of request with the displayed columns.
        # However, this will make testing more difficult and code more complex.
        prf = PrFetcher(settings.TOP_LEVEL_URL, settings.ORG, repos,
                        current_user)
        context = {
            "title": project,
            "projects": prf.get_prs(),
            "columns": column_names
        }

        after = time.time()
        logger.debug("page generated in %s sec" % (after - before))
        return render(request, 'pr.html', context)
    else:
        return HttpResponse("No projects found\n", status=404)