Skip to content

Commit f2223e2

Browse files
author
Gauvain Pocentek
committed
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
1 parent f8e6b13 commit f2223e2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

gitlab/mixins.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,11 @@ def time_stats(self, **kwargs):
477477
GitlabAuthenticationError: If authentication is not correct
478478
GitlabTimeTrackingError: If the time tracking update cannot be done
479479
"""
480+
# Use the existing time_stats attribute if it exist, otherwise make an
481+
# API call
482+
if 'time_stats' in self.attributes:
483+
return self.attributes['time_stats']
484+
480485
path = '%s/%s/time_stats' % (self.manager.path, self.get_id())
481486
return self.manager.gitlab.http_get(path, **kwargs)
482487

0 commit comments

Comments
 (0)