1

Hi to all and sorry for my English!

I need your help in this question: I have a list of the issues (among them are epics, tasks, stories, subtasks, etc.) In a certain way, I filtered IDs of such information and placed them in the list:

listOfKeys = [id1,id2,id3,id4,id5...]

Then, I need to get such a table (the data in which would be built on issues, which are in the listOfKeys ) as in the screenshot: see my screenshot

For this, I wrote this "code":

listOfWorklogs=pd.DataFrame()                #table from the screenshot (I used pandas (pd) lib)
lst={}                                       #dictionary for help, where the worklogs will be stored
for i in range(len(listOfKeys)):
    worklogs=jira.worklogs(listOfKeys[i])    #getting list of worklogs
    if(len(worklogs)) == 0:
        i+=1
    else:
        for j in range(len(worklogs)):
            lst = {
                    'self': worklogs[j].self,  
                    'author': worklogs[j].author,
                    'started': worklogs[j].started,
                    'created': worklogs[j].created,
                    'updated': worklogs[j].updated,
                    'timespent': worklogs[j].timeSpentSeconds
                }
            listOfWorklogs = listOfWorklogs.append(lst, ignore_index=True)
########### Below there is the recording to the .xlsx file ################

But it works very slowly, even for 100 issues (about 3 minutes). And I have about 10,000 issues ((( Perhaps there is some workaround? I will be glad to any advice, thanks.

1 Answers1

0

I've made your code slightly more pythonic, it might be slightly quicker using the iterators:

  list_of_keys = [
      id1, id2, id3, id4, id5
  ]

  resulting_logs = [] 
  for worklog_key in list_of_keys:
      worklogs = jira.worklogs(worklog_key)

      for log in worklogs:
          resulting_logs.append({
              'self': log.self,
              'author': log.author,
              'started': log.started,
              'created': log.created,
              'updated': log.updated,
              'timespent': log.timeSpentSeconds
          })

  df = pd.DataFrame(resulting_logs)

You also may be limited by the response time of the jira API.

However you can try using a list comprehension, haven't tested this though:

  list_of_keys = [
      id1, id2, id3, id4, id5
  ]

  def parse_log(log):
      return {
          'self': log.self,
          'author': log.author,
          'started': log.started,
          'created': log.created,
          'updated': log.updated,
          'timespent': log.timeSpentSeconds
      }


  resulting_logs = [
      parse_log(log)
      for log in jira.worklogs(key)                                                                          
      for key in list_of_keys
  ]

  df = pd.DataFrame(resulting_logs)

foxyblue
  • 2,859
  • 2
  • 21
  • 29