diff options
author | Gauvain Pocentek <gauvain@pocentek.net> | 2018-05-30 20:22:05 +0200 |
---|---|---|
committer | Gauvain Pocentek <gauvain@pocentek.net> | 2018-05-30 20:24:57 +0200 |
commit | f2223e2397aebd1a805bae25b0d6a5fc58519d5d (patch) | |
tree | 2744fec64e87c93defb79fe8ffdc70895e9fb47f /gitlab/mixins.py | |
parent | f8e6b13a2ed8d022ef206de809546dcc0318cd08 (diff) | |
download | gitlab-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.py | 5 |
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) |