Closed maricn closed 3 years ago
Looks like get_projects
's response can be reused without making additional request with jira.createmeta
in print_projects
.
To overcome the issue, I applied the following patch to VIRA-247
(e433204) that also takes care of parallelizing requests to the API:
diff --git a/python/Vira/vira_api.py b/python/Vira/vira_api.py
index 88d619d..cf83d44 100644
--- a/python/Vira/vira_api.py
+++ b/python/Vira/vira_api.py
@@ -379,10 +379,15 @@ class ViraAPI():
Build a vim pop-up menu for a list of projects
'''
- for project in self.get_projects():
- projectDesc = self.jira.createmeta(
- projectKeys=project, expand='projects')['projects'][0]
- print(str(project) + ' ~ ' + projectDesc['name'])
+ all_projects = self.get_projects()
+ batch_size = 10
+ project_batches = [all_projects[i:i + batch_size]
+ for i in range(0, len(all_projects), batch_size)]
+
+ for batch in project_batches:
+ projects = self.jira.createmeta(
+ projectKeys=','.join(batch), expand='projects')['projects']
+ [print(p['key'] + ' ~ ' + p['name']) for p in projects]
# print(self.jira.projects())
# vim.command('s:projects = [' + self.jira.projects() + ']')
The idea was to re-use the print and always keep refreshing the data in the menus is the idea as it is growing. I am sure my work arounds for more information than we were supposed to have was most of our pain but this one is a new on for sure. Must not delete enough projects.
I did a test on this with a few servers and had no issues. Feel free to make a pull request for it.
@maricn I have pushed this one in. I will hopefully get the async done tonight and then we will have something good for testing out there.
When approved I will close this issue
This issue doesn't appear any more, good to close. :)
I was going to wait for a push from you but I just did the copy and past. I will be wrapping up cleanup on that branch at least to dev
today and master
quickly.
branch
dev
: https://github.com/n0v1c3/vira/blob/be80ff2783302127bb7606d9acc845a2781f0888/python/Vira/vira_api.py#L380-L381branch
VIRA-247
: https://github.com/n0v1c3/vira/blob/e43320406c67831da35b88fcb56a235a9741fade/python/Vira/vira_api.py#L383-L384In response from:
I get several:
It seems JIRA API returns empty
"projects"
response for archived projects. Python pluginjira
usesissues/createmeta
which probably suffers from the same limitation mentioned here - archived projects have empty permission scheme so our user doesn't have the privilege to query it. (Maybe.)Anyways, trying to access
[0]
will causeIndexOutOfBounds
exception.