Skip to content

Commit

Permalink
time_stats(): use an existing attribute if available
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Gauvain Pocentek committed May 30, 2018
1 parent f8e6b13 commit f2223e2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gitlab/mixins.py
Expand Up @@ -477,6 +477,11 @@ def time_stats(self, **kwargs):
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)

Expand Down

3 comments on commit f2223e2

@ebergerson
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bravo. When will you rev the next version of the API? 1.4.1?

@gpocentek
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm targetting a 1.5 actually, but I can probably cherry-pick this change and push it to the 1.4 branch. I'll try try to do that + a release by the end of the week.

@ebergerson
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent. Thanks.

Please sign in to comment.