# HG changeset patch # User Daniel Dourvaris # Date 2020-01-16 07:51:35 # Node ID 01c1fb341b0d16f7bb31eca426e52ce4461d7ea9 # Parent bb0e450ff9c422f8dcea6e9582c669ab3e0532f5 API: added pull-requests versions into returned API data - fixes #5582 diff --git a/rhodecode/api/views/pull_request_api.py b/rhodecode/api/views/pull_request_api.py --- a/rhodecode/api/views/pull_request_api.py +++ b/rhodecode/api/views/pull_request_api.py @@ -73,6 +73,7 @@ def get_pull_request(request, apiuser, p "status" : "", "created_on": "", "updated_on": "", + "versions": "", "commit_ids": [ ... "", diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -4296,6 +4296,7 @@ class PullRequest(Base, _PullRequestBase def __json__(self): return { 'revisions': self.revisions, + 'versions': self.versions_count } def calculated_review_status(self): @@ -4318,6 +4319,14 @@ class PullRequest(Base, _PullRequestBase vcs_obj = self.target_repo.scm_instance() return vcs_obj.get_shadow_instance(shadow_repository_path) + @property + def versions_count(self): + """ + return number of versions this PR have, e.g a PR that once been + updated will have 2 versions + """ + return self.versions.count() + 1 + class PullRequestVersion(Base, _PullRequestBase): __tablename__ = 'pull_request_versions'