| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1b70580 commit f731707
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -225,3 +225,51 @@ Link issue ``i1`` to issue ``i2``:: | |||
| 225 | 225 | Delete a link:: | |
| 226 | 226 | ||
| 227 | 227 | i1.links.delete(issue_link_id) | |
| 228 | + | ||
| 229 | + Issues statistics | ||
| 230 | + ========================= | ||
| 231 | + | ||
| 232 | + Reference | ||
| 233 | + --------- | ||
| 234 | + | ||
| 235 | + * v4 API: | ||
| 236 | + | ||
| 237 | + + :class:`gitlab.v4.objects.IssuesStatistics` | ||
| 238 | + + :class:`gitlab.v4.objects.IssuesStatisticsManager` | ||
| 239 | + + :attr:`gitlab.issuesstatistics` | ||
| 240 | + + :class:`gitlab.v4.objects.GroupIssuesStatistics` | ||
| 241 | + + :class:`gitlab.v4.objects.GroupIssuesStatisticsManager` | ||
| 242 | + + :attr:`gitlab.v4.objects.Group.issuesstatistics` | ||
| 243 | + + :class:`gitlab.v4.objects.ProjectIssuesStatistics` | ||
| 244 | + + :class:`gitlab.v4.objects.ProjectIssuesStatisticsManager` | ||
| 245 | + + :attr:`gitlab.v4.objects.Project.issuesstatistics` | ||
| 246 | + | ||
| 247 | + | ||
| 248 | + * GitLab API: https://docs.gitlab.com/ce/api/issues_statistics.htm | ||
| 249 | + | ||
| 250 | + Examples | ||
| 251 | + --------- | ||
| 252 | + | ||
| 253 | + Get statistics of all issues the user has access to:: | ||
| 254 | + | ||
| 255 | + statistics = gl.issuesstatistics.get() | ||
| 256 | + | ||
| 257 | + Get statistics of issues for the user with ``foobar`` in ``title`` and ``description``:: | ||
| 258 | + | ||
| 259 | + statistics = gl.issuesstatistics.get(search='foobar') | ||
| 260 | + | ||
| 261 | + Get statistics of all issues in a group:: | ||
| 262 | + | ||
| 263 | + statistics = group.issuesstatistics.get() | ||
| 264 | + | ||
| 265 | + Get statistics of issues in a group with ``foobar`` in ``title`` and ``description``:: | ||
| 266 | + | ||
| 267 | + statistics = group.issuesstatistics.get(search='foobar') | ||
| 268 | + | ||
| 269 | + Get statistics of all issues in a project:: | ||
| 270 | + | ||
| 271 | + statistics = project.issuesstatistics.get() | ||
| 272 | + | ||
| 273 | + Get statistics of issues in a project with ``foobar`` in ``title`` and ``description``:: | ||
| 274 | + | ||
| 275 | + statistics = project.issuesstatistics.get(search='foobar') | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -768,29 +768,3 @@ Get all additional statistics of a project:: | |||
| 768 | 768 | Get total fetches in last 30 days of a project:: | |
| 769 | 769 | ||
| 770 | 770 | total_fetches = project.additionalstatistics.get().fetches['total'] | |
| 771 | - | ||
| 772 | - Project issues statistics | ||
| 773 | - ========================= | ||
| 774 | - | ||
| 775 | - Reference | ||
| 776 | - --------- | ||
| 777 | - | ||
| 778 | - * v4 API: | ||
| 779 | - | ||
| 780 | - + :class:`gitlab.v4.objects.ProjectIssuesStatistics` | ||
| 781 | - + :class:`gitlab.v4.objects.ProjectIssuesStatisticsManager` | ||
| 782 | - + :attr:`gitlab.v4.objects.Project.issuesstatistics` | ||
| 783 | - | ||
| 784 | - * GitLab API: https://docs.gitlab.com/ce/api/issues_statistics.html#get-project-issues-statistics | ||
| 785 | - | ||
| 786 | - Examples | ||
| 787 | - --------- | ||
| 788 | - | ||
| 789 | - Get statistics of all issues in a project:: | ||
| 790 | - | ||
| 791 | - statistics = project.issuesstatistics.get() | ||
| 792 | - | ||
| 793 | - Get statistics of issues in a project with ``foobar`` in ``title`` and | ||
| 794 | - ``description``:: | ||
| 795 | - | ||
| 796 | - statistics = project.issuesstatistics.get(search='foobar') | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -118,6 +118,7 @@ def __init__( | |||
| 118 | 118 | self.groups = objects.GroupManager(self) | |
| 119 | 119 | self.hooks = objects.HookManager(self) | |
| 120 | 120 | self.issues = objects.IssueManager(self) | |
| 121 | + self.issuesstatistics = objects.IssuesStatisticsManager(self) | ||
| 121 | 122 | self.ldapgroups = objects.LDAPGroupManager(self) | |
| 122 | 123 | self.licenses = objects.LicenseManager(self) | |
| 123 | 124 | self.namespaces = objects.NamespaceManager(self) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,6 +26,7 @@ | |||
| 26 | 26 | from .packages import GroupPackageManager # noqa: F401 | |
| 27 | 27 | from .projects import GroupProjectManager # noqa: F401 | |
| 28 | 28 | from .runners import GroupRunnerManager # noqa: F401 | |
| 29 | + from .statistics import GroupIssuesStatisticsManager # noqa: F401 | ||
| 29 | 30 | from .variables import GroupVariableManager # noqa: F401 | |
| 30 | 31 | ||
| 31 | 32 | __all__ = [ | |
@@ -52,6 +53,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject): | |||
| 52 | 53 | ("epics", "GroupEpicManager"), | |
| 53 | 54 | ("imports", "GroupImportManager"), | |
| 54 | 55 | ("issues", "GroupIssueManager"), | |
| 56 | + ("issuesstatistics", "GroupIssuesStatisticsManager"), | ||
| 55 | 57 | ("labels", "GroupLabelManager"), | |
| 56 | 58 | ("members", "GroupMemberManager"), | |
| 57 | 59 | ("members_all", "GroupMemberAllManager"), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,8 +2,12 @@ | |||
| 2 | 2 | from gitlab.mixins import GetWithoutIdMixin, RefreshMixin | |
| 3 | 3 | ||
| 4 | 4 | __all__ = [ | |
| 5 | + "GroupIssuesStatistics", | ||
| 6 | + "GroupIssuesStatisticsManager", | ||
| 5 | 7 | "ProjectAdditionalStatistics", | |
| 6 | 8 | "ProjectAdditionalStatisticsManager", | |
| 9 | + "IssuesStatistics", | ||
| 10 | + "IssuesStatisticsManager", | ||
| 7 | 11 | "ProjectIssuesStatistics", | |
| 8 | 12 | "ProjectIssuesStatisticsManager", | |
| 9 | 13 | ] | |
@@ -19,6 +23,25 @@ class ProjectAdditionalStatisticsManager(GetWithoutIdMixin, RESTManager): | |||
| 19 | 23 | _from_parent_attrs = {"project_id": "id"} | |
| 20 | 24 | ||
| 21 | 25 | ||
| 26 | + class IssuesStatistics(RefreshMixin, RESTObject): | ||
| 27 | + _id_attr = None | ||
| 28 | + | ||
| 29 | + | ||
| 30 | + class IssuesStatisticsManager(GetWithoutIdMixin, RESTManager): | ||
| 31 | + _path = "/issues_statistics" | ||
| 32 | + _obj_cls = IssuesStatistics | ||
| 33 | + | ||
| 34 | + | ||
| 35 | + class GroupIssuesStatistics(RefreshMixin, RESTObject): | ||
| 36 | + _id_attr = None | ||
| 37 | + | ||
| 38 | + | ||
| 39 | + class GroupIssuesStatisticsManager(GetWithoutIdMixin, RESTManager): | ||
| 40 | + _path = "/groups/%(group_id)s/issues_statistics" | ||
| 41 | + _obj_cls = GroupIssuesStatistics | ||
| 42 | + _from_parent_attrs = {"group_id": "id"} | ||
| 43 | + | ||
| 44 | + | ||
| 22 | 45 | class ProjectIssuesStatistics(RefreshMixin, RESTObject): | |
| 23 | 46 | _id_attr = None | |
| 24 | 47 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,16 @@ | |||
| 1 | 1 | """ | |
| 2 | 2 | GitLab API: https://docs.gitlab.com/ce/api/issues.html | |
| 3 | 3 | """ | |
| 4 | + import re | ||
| 4 | 5 | ||
| 5 | 6 | import pytest | |
| 6 | 7 | import responses | |
| 7 | 8 | ||
| 8 | - from gitlab.v4.objects import ProjectIssuesStatistics | ||
| 9 | + from gitlab.v4.objects import ( | ||
| 10 | + GroupIssuesStatistics, | ||
| 11 | + IssuesStatistics, | ||
| 12 | + ProjectIssuesStatistics, | ||
| 13 | + ) | ||
| 9 | 14 | ||
| 10 | 15 | ||
| 11 | 16 | @pytest.fixture | |
@@ -43,7 +48,9 @@ def resp_issue_statistics(): | |||
| 43 | 48 | with responses.RequestsMock() as rsps: | |
| 44 | 49 | rsps.add( | |
| 45 | 50 | method=responses.GET, | |
| 46 | - url="http://localhost/api/v4/projects/1/issues_statistics", | ||
| 51 | + url=re.compile( | ||
| 52 | + r"http://localhost/api/v4/((groups|projects)/1/)?issues_statistics" | ||
| 53 | + ), | ||
| 47 | 54 | json=content, | |
| 48 | 55 | content_type="application/json", | |
| 49 | 56 | status=200, | |
@@ -63,7 +70,19 @@ def test_get_issue(gl, resp_get_issue): | |||
| 63 | 70 | assert issue.name == "name" | |
| 64 | 71 | ||
| 65 | 72 | ||
| 66 | - def test_project_issues_statistics(project, resp_issue_statistics): | ||
| 73 | + def test_get_issues_statistics(gl, resp_issue_statistics): | ||
| 74 | + statistics = gl.issuesstatistics.get() | ||
| 75 | + assert isinstance(statistics, IssuesStatistics) | ||
| 76 | + assert statistics.statistics["counts"]["all"] == 20 | ||
| 77 | + | ||
| 78 | + | ||
| 79 | + def test_get_group_issues_statistics(group, resp_issue_statistics): | ||
| 80 | + statistics = group.issuesstatistics.get() | ||
| 81 | + assert isinstance(statistics, GroupIssuesStatistics) | ||
| 82 | + assert statistics.statistics["counts"]["all"] == 20 | ||
| 83 | + | ||
| 84 | + | ||
| 85 | + def test_get_project_issues_statistics(project, resp_issue_statistics): | ||
| 67 | 86 | statistics = project.issuesstatistics.get() | |
| 68 | 87 | assert isinstance(statistics, ProjectIssuesStatistics) | |
| 69 | 88 | assert statistics.statistics["counts"]["all"] == 20 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments