Exemple #1
0
def source(request):
    # pr相关数据
    pr_rs = get_all_ticket()
    pr_count = len(pr_rs)
    pr_open_count = len(filter(lambda x: x[1] is None, pr_rs))

    # issue相关数据
    issue_rs = get_all_issue()
    issue_count = len(issue_rs)
    issue_open_count = len(filter(lambda x: x[1] is None, issue_rs))

    project_rs = get_all_project()
    gist_rs = get_all_gist()

    data = dict(
        # pr相关数据
        pr_count=pr_count,
        pr_open_count=pr_open_count,
        pr_closed_count=pr_count - pr_open_count,
        pr_comment_count=get_ticket_comment_count(),
        # issue相关数据
        issue_count=issue_count,
        issue_open_count=issue_open_count,
        issue_closed_count=issue_count - issue_open_count,
        issue_comment_count=get_issue_comment_count(),
        # project相关数据
        project_count=len(project_rs),
        project_fork_count=len(filter(lambda x: x[1] is not None, project_rs)),
        # gist相关数据
        gist_count=len(gist_rs),
        gist_fork_count=len(filter(lambda x: x[1] != 0, gist_rs)),
    )

    return data
Exemple #2
0
def source(request):
    # pr相关数据
    pr_rs = get_all_ticket()
    pr_count = len(pr_rs)
    pr_open_count = len(filter(lambda x: x[1] is None, pr_rs))

    # issue相关数据
    issue_rs = get_all_issue()
    issue_count = len(issue_rs)
    issue_open_count = len(filter(lambda x: x[1] is None, issue_rs))

    project_rs = get_all_project()
    gist_rs = get_all_gist()

    data = dict(
        # pr相关数据
        pr_count=pr_count,
        pr_open_count=pr_open_count,
        pr_closed_count=pr_count - pr_open_count,
        pr_comment_count=get_ticket_comment_count(),
        # issue相关数据
        issue_count=issue_count,
        issue_open_count=issue_open_count,
        issue_closed_count=issue_count - issue_open_count,
        issue_comment_count=get_issue_comment_count(),
        # project相关数据
        project_count=len(project_rs),
        project_fork_count=len(filter(lambda x: x[1] is not None, project_rs)),
        # gist相关数据
        gist_count=len(gist_rs),
        gist_fork_count=len(filter(lambda x: x[1] != 0, gist_rs))
    )

    return data
Exemple #3
0
    def test_pr_stat(self):
        TestCase.setUp(self)
        _, self.proj1, _, self.proj1_fork = setup_repos(
            mkdtemp(), 'testproject1')
        _, self.proj2, _, self.proj2_fork = setup_repos(
            mkdtemp(), 'testproject2')
        pr_rs = get_all_ticket()
        assert len(pr_rs) == 0
        pr_open_count = len(filter(lambda x: x[1] is None, pr_rs))
        assert pr_open_count == 0
        assert len(pr_rs) - pr_open_count == 0

        pullreq1 = PullRequest.open(self.proj1_fork, 'master', self.proj1,
                                    'master')
        ticket1 = Ticket.add(self.proj1.id, 'title', 'content', 'testuser')
        pullreq1 = pullreq1.insert(ticket1.ticket_number)
        pullreq2 = PullRequest.open(self.proj2_fork, 'master', self.proj2,
                                    'master')
        ticket2 = Ticket.add(self.proj2.id, 'title', 'content', 'testuser')
        pullreq2 = pullreq2.insert(ticket2.ticket_number)
        pr_rs = get_all_ticket()
        assert len(pr_rs) == 2
        pr_open_count = len(filter(lambda x: x[1] is None, pr_rs))
        assert pr_open_count == 2
        assert len(pr_rs) - pr_open_count == 0

        ticket1.close("testuser")
        pr_rs = get_all_ticket()
        assert len(pr_rs) == 2
        pr_open_count = len(filter(lambda x: x[1] is None, pr_rs))
        assert pr_open_count == 1
        assert len(pr_rs) - pr_open_count == 1

        pr_comment_count = get_ticket_comment_count()
        assert (pr_comment_count) == 0
        ticket2.add_comment("comment1", "testuse1")
        ticket2.add_comment("comment2", "testuse2")
        pr_comment_count = get_ticket_comment_count()
        assert (pr_comment_count) == 2
Exemple #4
0
    def test_pr_stat(self):
        TestCase.setUp(self)
        _, self.proj1, _, self.proj1_fork = setup_repos(
            mkdtemp(), 'testproject1')
        _, self.proj2, _, self.proj2_fork = setup_repos(
            mkdtemp(), 'testproject2')
        pr_rs = get_all_ticket()
        assert len(pr_rs) == 0
        pr_open_count = len(filter(lambda x: x[1] is None, pr_rs))
        assert pr_open_count == 0
        assert len(pr_rs) - pr_open_count == 0

        pullreq1 = PullRequest.open(
            self.proj1_fork, 'master', self.proj1, 'master')
        ticket1 = Ticket.add(self.proj1.id, 'title', 'content', 'testuser')
        pullreq1 = pullreq1.insert(ticket1.ticket_number)
        pullreq2 = PullRequest.open(
            self.proj2_fork, 'master', self.proj2, 'master')
        ticket2 = Ticket.add(self.proj2.id, 'title', 'content', 'testuser')
        pullreq2 = pullreq2.insert(ticket2.ticket_number)
        pr_rs = get_all_ticket()
        assert len(pr_rs) == 2
        pr_open_count = len(filter(lambda x: x[1] is None, pr_rs))
        assert pr_open_count == 2
        assert len(pr_rs) - pr_open_count == 0

        ticket1.close("testuser")
        pr_rs = get_all_ticket()
        assert len(pr_rs) == 2
        pr_open_count = len(filter(lambda x: x[1] is None, pr_rs))
        assert pr_open_count == 1
        assert len(pr_rs) - pr_open_count == 1

        pr_comment_count = get_ticket_comment_count()
        assert(pr_comment_count) == 0
        ticket2.add_comment("comment1", "testuse1")
        ticket2.add_comment("comment2", "testuse2")
        pr_comment_count = get_ticket_comment_count()
        assert(pr_comment_count) == 2