Description
Description of the problem, including code/CLI snippet
I have used the api to grab a list of issues and iterate through them getting their time stats:
def display_issues(self, issues: Iterator[ProjectIssue]):
rows = []
for issue in issues:
row = {k: getattr(issue, k) for k in ['iid', 'title', 'state', 'closed_at']}
row['closed_at'] = pd.to_datetime(row['closed_at'], utc=True).strftime("%Y-%m-%d %H:%M") \
if row['closed_at'] else ""
ts = issue.time_stats()
row['estimate'] = ts['human_time_estimate']
row['spent'] = ts['human_total_time_spent']
row['assignee'] = issue.assignee['username'] if issue.assignee else ""
rows.append(row)
It takes a very long time. I discovered when running in debug mode that each call to time_stats() is failing once on an inappropriate formed URI. Here is the debugging output
DEBUG:root:Stage: Display Issues
DEBUG:urllib3.connectionpool:https://gitlab.com:443 "GET /api/v4/projects/5118242/issues//237/time_stats HTTP/1.1" 308 0
DEBUG:urllib3.connectionpool:Resetting dropped connection: gitlab.com
DEBUG:urllib3.connectionpool:https://gitlab.com:443 "GET /api/v4/projects/5118242/issues/237/time_stats HTTP/1.1" 200 105
DEBUG:urllib3.connectionpool:https://gitlab.com:443 "GET /api/v4/projects/5118242/issues//235/time_stats HTTP/1.1" 308 0
DEBUG:urllib3.connectionpool:Resetting dropped connection: gitlab.com
DEBUG:urllib3.connectionpool:https://gitlab.com:443 "GET /api/v4/projects/5118242/issues/235/time_stats HTTP/1.1" 200 105
DEBUG:urllib3.connectionpool:https://gitlab.com:443 "GET /api/v4/projects/5118242/issues//227/time_stats HTTP/1.1" 308 0
DEBUG:urllib3.connectionpool:Resetting dropped connection: gitlab.com
DEBUG:urllib3.connectionpool:https://gitlab.com:443 "GET /api/v4/projects/5118242/issues/227/time_stats HTTP/1.1" 200 97
DEBUG:urllib3.connectionpool:https://gitlab.com:443 "GET /api/v4/projects/5118242/issues//226/time_stats HTTP/1.1" 308 0
DEBUG:urllib3.connectionpool:Resetting dropped connection: gitlab.com
....
I have found the error is in this code:
class TimeTrackingMixin(object):
@cli.register_custom_action(('ProjectIssue', 'ProjectMergeRequest'))
@exc.on_http_error(exc.GitlabTimeTrackingError)
def time_stats(self, **kwargs):
"""Get time stats for the object.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabTimeTrackingError: If the time tracking update cannot be done
"""
path = '%s/%s/time_stats' % (self.manager.path, self.get_id())
return self.manager.gitlab.http_get(path, **kwargs)
Setting a breakpoint before the return we can see that the path is ill formed:
The problem is that the self.manager.path has a terminating /
.
Expected Behavior
Actual Behavior
Specifications
- python-gitlab version: 1.4.0
- API version you are using (v3/v4): V4
- Gitlab server version (or gitlab.com): GitLab.com