summaryrefslogtreecommitdiff
path: root/gitlab/mixins.py
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2018-05-30 20:22:05 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2018-05-30 20:24:57 +0200
commitf2223e2397aebd1a805bae25b0d6a5fc58519d5d (patch)
tree2744fec64e87c93defb79fe8ffdc70895e9fb47f /gitlab/mixins.py
parentf8e6b13a2ed8d022ef206de809546dcc0318cd08 (diff)
downloadgitlab-f2223e2397aebd1a805bae25b0d6a5fc58519d5d.tar.gz
time_stats(): use an existing attribute if available
A time_stats attribute is returned by GitLab when fetching issues and merge requests (on reasonably recent GitLab versions). Use this info instead of making a new API call if possible. Fixes #510
Diffstat (limited to 'gitlab/mixins.py')
-rw-r--r--gitlab/mixins.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/gitlab/mixins.py b/gitlab/mixins.py
index 05e31c0..966a647 100644
--- a/gitlab/mixins.py
+++ b/gitlab/mixins.py
@@ -477,6 +477,11 @@ class TimeTrackingMixin(object):
GitlabAuthenticationError: If authentication is not correct
GitlabTimeTrackingError: If the time tracking update cannot be done
"""
+ # Use the existing time_stats attribute if it exist, otherwise make an
+ # API call
+ if 'time_stats' in self.attributes:
+ return self.attributes['time_stats']
+
path = '%s/%s/time_stats' % (self.manager.path, self.get_id())
return self.manager.gitlab.http_get(path, **kwargs)