From f2223e2397aebd1a805bae25b0d6a5fc58519d5d Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Wed, 30 May 2018 20:22:05 +0200 Subject: 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 --- gitlab/mixins.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gitlab/mixins.py') 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) -- cgit v1.2.1