Commit 9fb7363d authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

list numbers of opened issues & PR in project tables

parent cdea649e
......@@ -12,7 +12,7 @@ import git
import requests
from autoslug import AutoSlugField
from ndh.models import Links, NamedModel, TimeStampedModel
from ndh.utils import enum_to_choices
from ndh.utils import enum_to_choices, query_sum
from .utils import SOURCES, TARGETS, slugify_with_dots, api_next
......@@ -243,6 +243,13 @@ class Project(Links, NamedModel, TimeStampedModel):
commits = self.git().git.rev_list(f'{self.version}..{self.main_branch()}')
return len(commits.split('\n')) if commits else 0
def open_issues(self):
return query_sum(self.repo_set, 'open_issues')
def open_pr(self):
return query_sum(self.repo_set, 'open_pr')
class Repo(TimeStampedModel):
name = models.CharField(max_length=200)
......@@ -31,6 +31,8 @@ class NamespaceTable(StrippedTable):
class ProjectTable(StrippedTable):
commits_since = tables.Column(accessor='commits_since', orderable=False)
repos = tables.Column(accessor='repos', orderable=False)
issues = tables.Column(accessor='open_issues', orderable=False)
pr = tables.Column(accessor='open_pr', orderable=False)
rpkgs = tables.Column(accessor='rpkgs', orderable=False)
class Meta:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment