[Libreoffice-commits] dev-tools.git: esc-reporting/esc-analyze.py esc-reporting/esc-report.py

jan Iversen jani at documentfoundation.org
Tue Dec 20 19:13:28 UTC 2016


 esc-reporting/esc-analyze.py |   18 -
 esc-reporting/esc-report.py  |  450 +++++++++++++++----------------------------
 2 files changed, 170 insertions(+), 298 deletions(-)

New commits:
commit c8775f5a99192c92bbf9b8b2544e937747059040
Author: jan Iversen <jani at documentfoundation.org>
Date:   Tue Dec 20 20:13:05 2016 +0100

    update to make report work with new data flow

diff --git a/esc-reporting/esc-analyze.py b/esc-reporting/esc-analyze.py
index 7d600a9..b217bdb 100755
--- a/esc-reporting/esc-analyze.py
+++ b/esc-reporting/esc-analyze.py
@@ -224,12 +224,14 @@ def util_create_statList():
 
 
 def util_check_mail(name, mail):
-    global cfg, statList
+    global statList
 
-    if mail in cfg['aliases']:
-      mail = cfg['aliases'][mail]
+    if mail in statList['aliases']:
+      mail = statList['aliases'][mail]
     if not mail in statList['people']:
       statList['people'][mail] = util_create_person_gerrit(name, mail)
+      if mail == '*DUMMY*':
+        statList['people'][mail]['licenseOK'] = True
     return mail
 
 
@@ -455,7 +457,7 @@ def analyze_qa():
               util_build_period_stat(xDate, email, 'qa', 'fixed')
 
 def analyze_myfunc():
-    global cfg, statList, openhubData, bugzillaData, gerritData, gitData, aliasData, licenceCompanyData, licencePersonalData
+    global cfg, statList, openhubData, bugzillaData, gerritData, gitData, licenceCompanyData, licencePersonalData
 
     print("myfunc: analyze nothing", flush=True)
 
@@ -521,18 +523,18 @@ def runLoadCSV():
 
     try:
       fileName = cfg['homedir'] + 'gitdm-config/aliases'
-      cfg['aliases'] = util_load_csv(fileName, ' ')
+      statList['aliases'] = util_load_csv(fileName, ' ')
       fileName = cfg['homedir'] + 'gitdm-config/licenseCompany.csv'
       cfg['companies'] = util_load_csv(fileName, ';')
       fileName = cfg['homedir'] + 'gitdm-config/licensePersonal.csv'
       licencePersonalData = util_load_csv(fileName, ';')
 
       # check consistency
-      for i in cfg['aliases']:
+      for i in statList['aliases']:
         if i in licencePersonalData:
           raise Exception('alias ' + i + ' in aliases is licensed')
-        elif cfg['aliases'][i] not in licencePersonalData:
-          raise Exception('target ' + cfg['aliases'][i] + ' for alias ' + i + ' in aliases is NOT licensed')
+        elif statList['aliases'][i] not in licencePersonalData:
+          raise Exception('target ' + statList['aliases'][i] + ' for alias ' + i + ' in aliases is NOT licensed')
 
       # create base people info
       for id, row in licencePersonalData.items():
diff --git a/esc-reporting/esc-report.py b/esc-reporting/esc-report.py
index 6281b45..095ffea 100755
--- a/esc-reporting/esc-report.py
+++ b/esc-reporting/esc-report.py
@@ -52,13 +52,14 @@ def util_load_data_file(fileName):
 
 
 
-def util_check_mail(mail, statList, combineMail):
-    if mail in combineMail:
-      mail = combineMail[mail]
+def util_check_mail(mail):
+    global statList
+    if mail in statList['aliases']:
+      mail = statList['aliases'][mail]
     if not mail in statList['people']:
-      print('Error mail ' + mail + ' not in stats.json/people')
-      exit(-1)
-    return mail
+      return None
+    else:
+      return mail
 
 
 
@@ -72,38 +73,36 @@ def util_formatGerrit(id, owner, title):
 
 
 
-def util_print_line(fp, loopList, title, doGerrit=False, doBugzilla=False, doName=None):
+def util_print_line(fp, loopList, title, doGerrit=False, doBugzilla=False):
     print("\n\n" + title + ':', file=fp)
-    for i in loopList:
+    for row in loopList:
       if doGerrit:
-        x = 'https://gerrit.libreoffice.org/#/c/{}   {} -> "{}"'.format(i['id'], i['email'], i['title'])
+        x = 'https://gerrit.libreoffice.org/#/c/{}   {} -> "{}"'.format(row['id'], row['email'], row['title'])
       elif doBugzilla:
-        x = 'https://bugs.documentfoundation.org/show_bug.cgi?id=' + i
-      elif not doName is None:
-        x = i + '    ' + doName[i]['name']
+        x = 'https://bugs.documentfoundation.org/show_bug.cgi?id=' + row
+      elif 'id' in row:
+        x = '{} {} {} {}'.format(row['name'], row['email'], row['license'], row['id'])
       else:
-        x = i
+        x = '{} {} {}'.format(row['name'], row['email'], row['license'])
       print('    ' + x, file=fp)
 
 
 
-def util_build_escNumber(db, tag, statList):
+def util_build_escNumber(db, tag):
+    global statList
     return str(statList['data'][db][tag]) + '(' + str(statList['data'][db][tag]) + ')'
 
 
 
-def util_build_matrix(title, lineDesc, index, statList):
+def util_build_matrix(title, lineDesc, index):
+    global statList
     xValue = [[title, '1 week', '', '1 month', '', '3 months', '', '12 months', '']]
     xLen = [len(xValue[0][0]), 0, 0, 0, 0, 0, 0, 0, 0]
     for row in lineDesc:
       xLine = [row['text']]
       for i in '1week', '1month', '3month', '1year':
-        if index is None:
-          x1 = statList['data'][row['db']][i][row['tag']]
-          x2 = statList['diff'][row['db']][i][row['tag']]
-        else:
-          x1 = statList['data'][row['db']][index][i][row['tag']]
-          x2 = statList['diff'][row['db']][index][i][row['tag']]
+        x1 = statList['data'][row['db']][index][i][row['tag']]
+        x2 = statList['diff'][row['db']][index][i][row['tag']]
         xLine.append(str(x1))
         xLine.append('(' + str(x2) + ')')
       xValue.append(xLine)
@@ -128,53 +127,56 @@ def util_build_matrix(title, lineDesc, index, statList):
 
 
 
-def report_mentoring(statList, openhubData, gerritData, gitData, bugzillaData, cfg):
-    myStatList = {'missing_license': {},
-                  'to_abandon': [],
-                  'to_review': [],
-                  'we_miss_you_email': [],
-                  'remove_cc': [],
-                  'needsDevEval': [],
+def report_mentoring():
+    global statList, openhubData, gerritData, gitData, bugzillaData, cfg
+    myStatList = {'needsDevEval': [],
                   'needsUXEval': [],
                   'missing_ui_cc': [],
                   'needinfo': [],
+                  'to_be_closed': [],
+                  'easyhacks_new': [],
                   'to_unassign': [],
-                  'assign_problem': [],
                   'too_many_comments': [],
                   'missing_cc': [],
-                  'to_be_closed': [],
-                  'easyhacks_new': [],
+                  'assign_problem': [],
+                  'we_miss_you_email': [],
+                  'award_1st_email': [],
+                  'pending_license': [],
+                  'missing_license': [],
+                  'to_abandon' : [],
+                  'to_review': [],
                   'top10commit': [],
                   'top10review': [],
-                  'welcome_back_email': [],
-                  'award_1st_email': []}
-
+                  'remove_cc': []
+                  }
     mailedDate = datetime.datetime.strptime(cfg['git']['last-mail-run'], '%Y-%m-%d') - datetime.timedelta(days=90)
-    zDate = datetime.datetime(year=2001, month=1, day=1)
-    for i in statList['people']:
-      row = statList['people'][i]
-      if not row['hasLicense'] and row['isContributor'] and row['commits']['1month']['merged'] != 0:
-        myStatList['missing_license'][row['email']] = row['name']
-      if row['commits']['1year']['merged'] == row['commits']['1month']['merged'] and \
-         row['commits']['1month']['merged'] != 0 and not row['email'] in cfg['contributor']['award-mailed']:
-        myStatList['award_1st_email'].append(row['email'])
-
+    zeroDate = datetime.datetime(year=2001, month=1, day=1)
+    for id, row in statList['people'].items():
+      entry = {'name': row['name'], 'email': id, 'license': row['licenseText']}
       newestCommitDate = datetime.datetime.strptime(row['newestCommit'], '%Y-%m-%d')
-      prevCommitDate = datetime.datetime.strptime(row['prevCommit'], '%Y-%m-%d')
-      if newestCommitDate >= mailedDate and \
-         newestCommitDate < cfg['3monthDate']:
-        myStatList['we_miss_you_email'].append(i)
-      delta = newestCommitDate - prevCommitDate
-      if delta > datetime.timedelta(days=180) and prevCommitDate != zDate and \
-         newestCommitDate > cfg['1weekDate'] :
-        myStatList['welcome_back_email'].append(i)
-
-    for key in gerritData['patch']:
-      row = gerritData['patch'][key]
+      if newestCommitDate >= mailedDate and newestCommitDate < cfg['3monthDate']:
+        myStatList['we_miss_you_email'].append(entry)
+      x = row['commits']['3month']['owner']
+      if x != 0 and row['commits']['total'] == x and  not id in cfg['award-mailed']:
+        myStatList['award_1st_email'].append(entry)
+      if row['licenseText'].startswith('PENDING'):
+        myStatList['pending_license'].append(entry)
+
+    for key,row in gerritData['patch'].items():
       if row['status'] == 'SUBMITTED' or row['status'] == 'DRAFT':
         row['status'] = 'NEW'
       xDate = datetime.datetime.strptime(row['updated'], '%Y-%m-%d %H:%M:%S.%f000')
-      ownerEmail = util_check_mail(row['owner']['email'], statList, cfg['contributor']['combine-email'])
+      ownerEmail = util_check_mail(row['owner']['email'])
+      entry = {'id': key, 'name': row['owner']['name'], 'email': ownerEmail, 'title': row['subject']}
+      if row['status'] != 'ABANDONED':
+        if ownerEmail is None:
+          ownerEmail = row['owner']['email']
+          entry['email'] = ownerEmail
+          entry['license'] = 'GERRIT NO LICENSE'
+          myStatList['missing_license'].append(entry)
+        elif not statList['people'][ownerEmail]['licenseOK']:
+          entry['license'] = 'GERRIT: ' + statList['people'][ownerEmail]['licenseText']
+          myStatList['missing_license'].append(entry)
 
       if row['status'] == 'NEW':
         doBlock = False
@@ -186,9 +188,21 @@ def report_mentoring(statList, openhubData, gerritData, gitData, bugzillaData, c
             if x['email'] != ownerEmail and x['email'] != 'ci at libreoffice.org':
               cntReview += 1
         if xDate < cfg['1monthDate'] and not doBlock:
-            myStatList['to_abandon'].append({'id': key, 'email': row['owner']['email'], 'title': row['subject']})
+            myStatList['to_abandon'].append(entry)
         if cntReview == 0 and not statList['people'][ownerEmail]['isCommitter']:
-          myStatList['to_review'].append({'id': key, 'email': row['owner']['email'], 'title': row['subject']})
+          myStatList['to_review'].append(entry)
+
+    for key,row in gitData['commits'].items():
+      for i in 'author', 'committer':
+        email = util_check_mail(row[i+'-email'])
+        entry = {'id': key, 'name': row[i], 'email': email}
+        if email is None:
+          entry['email'] = row['author-email']
+          entry['license'] = 'GIT AUTHOR NO LICENSE'
+          myStatList['missing_license'].append(entry)
+        elif not statList['people'][ownerEmail]['licenseOK']:
+          entry['license'] = 'GIT: ' + statList['people'][email]['licenseText']
+          myStatList['missing_license'].append(entry)
 
     for key, row in bugzillaData['bugs'].items():
       if not 'cc' in row:
@@ -210,91 +224,65 @@ def report_mentoring(statList, openhubData, gerritData, gitData, bugzillaData, c
         myStatList['needsUXEval'].append(key)
       if 'topicUI' in row['keywords'] and 'libreoffice-ux-advise at lists.freedesktop.org' not in row['cc']:
         myStatList['missing_ui_cc'].append(key)
-
       if row['status'] == 'NEEDINFO':
         myStatList['needinfo'].append(key)
       elif row['status'] == 'ASSIGNED':
         xDate = datetime.datetime.strptime(row['last_change_time'], "%Y-%m-%dT%H:%M:%SZ")
         if xDate < cfg['1monthDate']:
           myStatList['to_unassign'].append(key)
-
-      if (row['status'] == 'ASSIGNED' and row['assigned_to'] == '') or \
-         (row['status'] != 'ASSIGNED' and row['assigned_to'] != '' and \
-          row['assigned_to'] != 'libreoffice-bugs at lists.freedesktop.org') :
-        myStatList['assign_problem'].append(key)
-
+        if row['assigned_to'] == '' or (row['assigned_to'] != '' and row['assigned_to'] != 'libreoffice-bugs at lists.freedesktop.org') :
+          myStatList['assign_problem'].append(key)
       if len(row['comments']) >= 5:
         myStatList['too_many_comments'].append(key)
-
       if not 'jani at documentfoundation.org' in row['cc']:
         myStatList['missing_cc'].append(key)
-
-      if row['comments'][-1]['creator'] == 'libreoffice-commits at lists.freedesktop.org' and \
-         not key in cfg['bugzilla']['close_except']:
+      if row['comments'][-1]['creator'] == 'libreoffice-commits at lists.freedesktop.org' and not key in cfg['bugzilla']['close_except']:
         myStatList['to_be_closed'].append(key)
-
       cDate = datetime.datetime.strptime(row['creation_time'], "%Y-%m-%dT%H:%M:%SZ")
       if cDate >= cfg['1weekDate'] or 'easyhack' in row['history'][-1]['changes'][0]['added']:
         myStatList['easyhacks_new'].append(key)
-
-    tmpClist = sorted(statList['people'], key=lambda k: (statList['people'][k]['commits']['1month']['merged']), reverse=True)
-    for i in tmpClist:
-      if not statList['people'][i]['isCommitter']:
-        x = {'mail': i, 'name': statList['people'][i]['name'],
-             'month' :statList['people'][i]['commits']['1month']['merged'],
-             'year':statList['people'][i]['commits']['1year']['merged']}
-        myStatList['top10commit'].append(x)
-        if len(myStatList['top10commit']) >= 10:
-          break
-    tmpRlist = sorted(statList['people'], key=lambda k: (statList['people'][k]['gerrit']['1month']['reviewer']), reverse=True)
-    for i in tmpRlist:
-      if i != 'ci at libreoffice.org':
-        x = {'mail': i, 'name': statList['people'][i]['name'],
-             'month' :statList['people'][i]['gerrit']['1month']['reviewer'],
-             'year':statList['people'][i]['gerrit']['1year']['reviewer']}
-        myStatList['top10review'].append(x)
-        if len(myStatList['top10review']) >= 10:
-          break
-
-    fp = open('/tmp/esc_mentoring_report.txt', 'w', encoding='utf-8')
-    print('ESC mentoring report, generated {} based on stats.json from {}'.format(
-           datetime.datetime.now().strftime("%Y-%m-%d"), statList['addDate']), file=fp)
+      tmpClist = sorted(statList['people'], key=lambda k: (statList['people'][k]['commits']['1month']['owner']),reverse=True)
+      for i in tmpClist:
+          if not statList['people'][i]['isCommitter']:
+              x = {'mail': i, 'name': statList['people'][i]['name'],
+                   'month': statList['people'][i]['commits']['1month']['owner'],
+                   'year': statList['people'][i]['commits']['1year']['owner']}
+              myStatList['top10commit'].append(x)
+              if len(myStatList['top10commit']) >= 10:
+                  break
+      tmpRlist = sorted(statList['people'], key=lambda k: (statList['people'][k]['gerrit']['1month']['reviewer']),reverse=True)
+      for i in tmpRlist:
+          if i != 'ci at libreoffice.org':
+              x = {'mail': i, 'name': statList['people'][i]['name'],
+                   'month': statList['people'][i]['gerrit']['1month']['reviewer'],
+                   'year': statList['people'][i]['gerrit']['1year']['reviewer']}
+              myStatList['top10review'].append(x)
+              if len(myStatList['top10review']) >= 10:
+                  break
+
+              fp = open('/tmp/esc_mentoring_report.txt', 'w', encoding='utf-8')
+              print('ESC mentoring report, generated {} based on stats.json from {}'.format(
+                  datetime.datetime.now().strftime("%Y-%m-%d"), statList['addDate']), file=fp)
 
     print("copy/paste to esc pad:\n"
           "* mentoring/easyhack update (janI)\n"
-          "    + openhub statistics based on analysis from {}\n"
-          "      {} people did in total: {} commits in {} lines of code\n"
-          "      {} people did in 12 month: {} commits\n"
+          "    + openhub statistics ({}), {} people did {} commits in 12 month in {} lines of code\n"
           "    + gerrit/git statistics:".format(
           statList['stat']['openhub_last_analyse'],
-          util_build_escNumber('openhub', 'total_contributors', statList),
-          util_build_escNumber('openhub', 'total_commits', statList),
-          util_build_escNumber('openhub', 'lines_of_code', statList),
-          util_build_escNumber('openhub', 'year_contributors', statList),
-          util_build_escNumber('openhub', 'year_commits', statList)), file=fp)
-
-    xRow = [{'db': 'gerrit',  'tag': 'NEW',       'text': 'open'},
-            {'db': 'gerrit',  'tag': 'reviewed',  'text': 'reviews'},
-            {'db': 'gerrit',  'tag': 'MERGED',    'text': 'merged'},
-            {'db': 'gerrit',  'tag': 'ABANDONED', 'text': 'abandoned'},
-            {'db': 'commits', 'tag': '#',         'text': 'commits'}]
-    print(util_build_matrix('committer...', xRow, 'committer', statList), end='', file=fp)
-    print(util_build_matrix('contributor...', xRow, 'contributor', statList), end='', file=fp)
-
-    print("    + Distribution of people based on number of merged patches:", file=fp)
-    xRow = [{'db': 'trendCommitter',  'tag': '1-5',    'text': '1-5'},
-            {'db': 'trendCommitter',  'tag': '6-25',   'text': '6-25'},
-            {'db': 'trendCommitter',  'tag': '26-50',  'text': '26-50'},
-            {'db': 'trendCommitter',  'tag': '51-100', 'text': '51-100'},
-            {'db': 'trendCommitter',  'tag': '100+',   'text': '100+'}]
-    print(util_build_matrix('Committer distribution', xRow, None, statList), end='', file=fp)
-    for i in xRow:
-      i['db'] = 'trendContributor'
-    print(util_build_matrix('Contributor distribution', xRow, None, statList), end='', file=fp)
-
+          util_build_escNumber('openhub', 'year_contributors'),
+          util_build_escNumber('openhub', 'year_commits'),
+          util_build_escNumber('openhub', 'lines_of_code')), file=fp)
+    xRow = [{'db': 'gerrit',  'tag': 'NEW',          'text': 'open'},
+            {'db': 'gerrit',  'tag': 'reviewed',     'text': 'reviews'},
+            {'db': 'gerrit',  'tag': 'MERGED',       'text': 'merged'},
+            {'db': 'gerrit',  'tag': 'ABANDONED',    'text': 'abandoned'},
+            {'db': 'commits', 'tag': 'owner',        'text': 'own commits'},
+            {'db': 'commits', 'tag': 'reviewMerged', 'text': 'review commits'}]
+    print(util_build_matrix('committer...', xRow, 'committer'), end='', file=fp)
+    print(util_build_matrix('contributor...', xRow, 'contributor'), end='', file=fp)
     print("    + easyHack statistics:\n       ", end='', file=fp)
     for i1 in 'needsDevEval', 'needsUXEval', 'cleanup_comments', 'total', 'assigned', 'open':
-      print(i1 + ' ' + util_build_escNumber('easyhacks', i1, statList) + '   ', end="", file=fp)
+      print(i1 + ' ' + util_build_escNumber('easyhacks', i1) + '   ', end="", file=fp)
       if i1 == 'cleanup_comments':
         print('\n       ', end='', file=fp)
     print("\n    + received patches from " + str(len(myStatList['missing_license'])) + " emails the last month without licesense statement",  file=fp)
@@ -312,19 +300,17 @@ def report_mentoring(statList, openhubData, gerritData, gitData, bugzillaData, c
             myStatList['top10review'][i]['year']), file=fp)
 
     print("    + big CONGRATULATIONS to contributors who have at least 1 merged patch, since last report:", file=fp)
-    for i in myStatList['award_1st_email']:
-        print('          ' + statList['people'][i]['name'], file=fp)
+    for row in myStatList['award_1st_email']:
+        print('          ' + row['name'], file=fp)
     print("\n\n\n\n\n\n\n\n\n\n", file=fp)
-
     print('Day mentoring report, generated {} based on stats.json from {}'.format(
            datetime.datetime.now().strftime("%Y-%m-%d"), statList['addDate']), file=fp)
 
-    util_print_line(fp, myStatList['welcome_back_email'], 'welcome back',              doName=statList['people'])
-    util_print_line(fp, myStatList['missing_license'],    'missing license statement', doName=statList['people'])
+    util_print_line(fp, myStatList['missing_license'],    'missing license statement'  )
     util_print_line(fp, myStatList['to_abandon'],         'gerrit to abandon',         doGerrit=True)
     util_print_line(fp, myStatList['to_review'],          'gerrit to review',          doGerrit=True)
     util_print_line(fp, myStatList['to_unassign'],        'easyhacks to unassign',     doBugzilla=True)
-    util_print_line(fp, myStatList['needinfo'],           'easyhacks with NEEDINFO',     doBugzilla=True)
+    util_print_line(fp, myStatList['needinfo'],           'easyhacks with NEEDINFO',   doBugzilla=True)
     util_print_line(fp, myStatList['easyhacks_new'],      'easyhacks new',             doBugzilla=True)
     util_print_line(fp, myStatList['missing_cc'],         'easyhacks missing cc',      doBugzilla=True)
     util_print_line(fp, myStatList['remove_cc'],          'easyhacks remove cc',       doBugzilla=True)
@@ -333,22 +319,25 @@ def report_mentoring(statList, openhubData, gerritData, gitData, bugzillaData, c
     util_print_line(fp, myStatList['to_be_closed'],       'easyhacks to be closed',    doBugzilla=True)
     util_print_line(fp, myStatList['needsDevEval'],       'easyhacks needsDevEval',    doBugzilla=True)
     util_print_line(fp, myStatList['needsUXEval'],        'easyhacks needsUXEval',     doBugzilla=True)
-    util_print_line(fp, myStatList['we_miss_you_email'],  'we miss you email',         doName=statList['people'])
+    util_print_line(fp, myStatList['we_miss_you_email'],  'we miss you email'          )
     util_print_line(fp, myStatList['too_many_comments'],  'easyhacks reduce comments', doBugzilla=True)
+    util_print_line(fp, myStatList['pending_license'],    'pending license statement'  )
     fp.close()
-
     return {'title': 'esc_mentoring, MENTORING', 'mail': 'jani at documentfoundation.org', 'file': '/tmp/esc_mentoring_report.txt'}
 
 
 
-def report_ui(statList, openhubData, gerritData, gitData, bugzillaData, cfg):
-    tmpClist = sorted(statList['people'], key=lambda k: (statList['people'][k]['ui']['1month']['total']), reverse=True)
+def report_ui():
+    global statList, openhubData, gerritData, gitData, bugzillaData, cfg
+    tmpClist = sorted(statList['people'], key=lambda k: (statList['people'][k]['ui']['1month']['history']+statList['people'][k]['ui']['1month']['commented']), reverse=True)
     top10list = []
     for i in tmpClist:
       if i != 'qa-admin at libreoffice.org' and i != 'libreoffice-commits at lists.freedesktop.org':
+        xYear = statList['people'][i]['ui']['1year']['history'] + statList['people'][i]['ui']['1year']['commented']
+        xMonth = statList['people'][i]['ui']['1month']['history'] + statList['people'][i]['ui']['1month']['commented']
         x = {'mail': i, 'name': statList['people'][i]['name'],
-             'month' :statList['people'][i]['ui']['1month']['total'],
-             'year':statList['people'][i]['ui']['1year']['total']}
+             'month' : xMonth,
+             'year': xYear}
         top10list.append(x)
         if len(top10list) >= 10:
           break
@@ -362,22 +351,14 @@ def report_ui(statList, openhubData, gerritData, gitData, bugzillaData, cfg):
           "    + Bugzilla (topicUI) statistics\n"
           "        {} (topicUI) bugs open, {} (needsUXEval) needs to be evaluated by the UXteam\n"
           "    + Updates:".format(
-          util_build_escNumber('ui', 'topicUI', statList),
-          util_build_escNumber('ui', 'needsUXEval', statList)), file=fp)
+          util_build_escNumber('ui', 'topicUI'),
+          util_build_escNumber('ui', 'needsUXEval')), file=fp)
 
     xRow = [{'db': 'ui', 'tag': 'added',     'text': 'added'},
             {'db': 'ui', 'tag': 'commented', 'text': 'commented'},
             {'db': 'ui', 'tag': 'removed',   'text': 'removed'},
             {'db': 'ui', 'tag': 'resolved',  'text': 'resolved'}]
-    print(util_build_matrix('BZ changes', xRow, None, statList), end='', file=fp)
-#    print("    + Distribution of people based on number of changes:", file=fp)
-#    xRow = [{'db': 'trendUI',  'tag': '1-5',    'text': '1-5'},
-#            {'db': 'trendUI',  'tag': '6-25',   'text': '6-25'},
-#            {'db': 'trendUI',  'tag': '26-50',  'text': '26-50'},
-#            {'db': 'trendUI',  'tag': '51-100', 'text': '51-100'},
-#            {'db': 'trendUI',  'tag': '100+',   'text': '100+'}]
-#    print(util_build_matrix('distribution', xRow, None, statList), end='', file=fp)
-
+    print(util_build_matrix('BZ changes', xRow, 'contributor'), end='', file=fp)
     print("    + top 10 contributors:", file=fp)
     for i in range(0, 10):
       print('          {} made {} changes in 1 month, and {} changes in 1 year'.format(
@@ -388,27 +369,28 @@ def report_ui(statList, openhubData, gerritData, gitData, bugzillaData, cfg):
 
 
 
-def report_qa(statList, openhubData, gerritData, gitData, bugzillaData, cfg):
+def report_qa():
+    global statList, openhubData, gerritData, gitData, bugzillaData, cfg
+    return
+    tmpClist = sorted(statList['people'], key=lambda k: (statList['people'][k]['qa']['1month']['total']), reverse=True)
+    top10list = []
+    for i in tmpClist:
+      if i != 'qa-admin at libreoffice.org' and i != 'libreoffice-commits at lists.freedesktop.org':
+        x = {'mail': i, 'name': statList['people'][i]['name'],
+             'month' :statList['people'][i]['qa']['1month']['total'],
+             'year':statList['people'][i]['qa']['1year']['total']}
+        top10list.append(x)
+        if len(top10list) >= 10:
+          break
 
     fp = open('/tmp/esc_qa_report.txt', 'w', encoding='utf-8')
     print('ESC QA report, generated {} based on stats.json from {}'.format(
           datetime.datetime.now().strftime("%Y-%m-%d"), statList['addDate']), file=fp)
 
     print("copy/paste to esc pad:\n"
-          "* qa update (xisco)\n", file=fp)
-
-    print("    + UNCONFIRMED: {} ( )\n"
-        "        + enhancements: {}  ( )\n"
-        "        + needsUXEval: {} ( )\n"
-        "        + haveBackTrace: {} ( )\n"
-        "        + needsDevAdvice: {} ( )\n".format(
-                    statList['data']['qa']['unconfirmed']['count'],
-                    statList['data']['qa']['unconfirmed']['enhancement'],
-                    statList['data']['qa']['unconfirmed']['needsUXEval'],
-                    statList['data']['qa']['unconfirmed']['haveBacktrace'],
-                    statList['data']['qa']['unconfirmed']['needsDevAdvice'],), file=fp)
-
-    print("\n    + Bugzilla statistics:", file=fp)
+          "* qa update (xisco)\n"
+          "    + Bugzilla statistics", file=fp)
+
     xRow = [{'db': 'qa',  'tag': 'ASSIGNED',       'text': 'ASSIGNED'},
             {'db': 'qa',  'tag': 'CLOSED',  'text': 'CLOSED'},
             {'db': 'qa',  'tag': 'NEEDINFO',  'text': 'NEEDINFO'},
@@ -429,141 +411,25 @@ def report_qa(statList, openhubData, gerritData, gitData, bugzillaData, cfg):
             {'db': 'trendQA',  'tag': '100+',   'text': '100+'}]
     print(util_build_matrix('distribution', xRow, None, statList), end='', file=fp)
 
-    tmpClist = sorted(statList['people'], key=lambda k: (statList['people'][k]['qa']['1week']['owner']), reverse=True)
-    top10reporters = []
-    for i in tmpClist:
-      if i != 'qa-admin at libreoffice.org' and i != 'libreoffice-commits at lists.freedesktop.org':
-        x = {'mail': i,
-             'name': statList['people'][i]['name'],
-             'week' :statList['people'][i]['qa']['1week']['owner'],
-             'month' :statList['people'][i]['qa']['1month']['owner'],
-             '3month':statList['people'][i]['qa']['3month']['owner']}
-        top10reporters.append(x)
-        if len(top10reporters) >= 10:
-          break
-
-    print("\n    + top 10 bugs reporters:", file=fp)
-    xRow = []
-    for i in top10reporters:
-      print('          {} reported {} bugs in 1 week, {} bugs in 1 month and {} bugs in 3 months'.format(
-            i['name'], i['week'], i['month'], i['3month']), file=fp)
-
-
-    tmpClist = sorted(statList['people'], key=lambda k: (statList['people'][k]['qa']['1week']['fixed']), reverse=True)
-    top10fixers = []
-    for i in tmpClist:
-      if i != 'qa-admin at libreoffice.org' and i != 'libreoffice-commits at lists.freedesktop.org':
-        x = {'mail': i,
-             'name': statList['people'][i]['name'],
-             'week' :statList['people'][i]['qa']['1week']['fixed'],
-             'month' :statList['people'][i]['qa']['1month']['fixed'],
-             '3month':statList['people'][i]['qa']['3month']['fixed']}
-        top10fixers.append(x)
-        if len(top10fixers) >= 10:
-          break
-
-    print("\n    + top 10 bugs fixers:", file=fp)
-    xRow = []
-    for i in top10fixers:
-      print('          {} fixed {} bugs in 1 week, {} bugs in 1 month and {} bugs in 3 months'.format(
-            i['name'], i['week'], i['month'], i['3month']), file=fp)
-
-
-    tmpClist = sorted(statList['people'], key=lambda k: (statList['people'][k]['qa']['1week']['bisected']), reverse=True)
-    top10bisected = []
-    for i in tmpClist:
-      if i != 'qa-admin at libreoffice.org' and i != 'libreoffice-commits at lists.freedesktop.org' and \
-        statList['people'][i]['qa']['1week']['bisected'] > 0:
-        x = {'mail': i,
-             'name': statList['people'][i]['name'],
-             'week' :statList['people'][i]['qa']['1week']['bisected'],
-             'month' :statList['people'][i]['qa']['1month']['bisected'],
-             '3month':statList['people'][i]['qa']['3month']['bisected']}
-        top10bisected.append(x)
-        if len(top10bisected) >= 10:
-          break
-
-    print("\n    + Done by:", file=fp)
-    xRow = []
-    for i in top10bisected:
-      print('          {} bisected {} bugs in 1 week, {} bugs in 1 month and {} bugs in 3 months'.format(
-            i['name'], i['week'], i['month'], i['3month']), file=fp)
-
-
-    tmpClist = sorted(statList['people'], key=lambda k: (statList['people'][k]['qa']['1week']['bibisected']), reverse=True)
-    top10bibisected = []
-    for i in tmpClist:
-      if i != 'qa-admin at libreoffice.org' and i != 'libreoffice-commits at lists.freedesktop.org' and \
-        statList['people'][i]['qa']['1week']['bibisected'] > 0:
-        x = {'mail': i,
-             'name': statList['people'][i]['name'],
-             'week' :statList['people'][i]['qa']['1week']['bibisected'],
-             'month' :statList['people'][i]['qa']['1month']['bibisected'],
-             '3month':statList['people'][i]['qa']['3month']['bibisected']}
-        top10bibisected.append(x)
-        if len(top10bibisected) >= 10:
-          break
-
-    print("\n    + Done by:", file=fp)
-    xRow = []
-    for i in top10bibisected:
-      print('          {} bibisected {} bugs in 1 week, {} bugs in 1 month and {} bugs in 3 months'.format(
-            i['name'], i['week'], i['month'], i['3month']), file=fp)
-
-
-    tmpClist = sorted(statList['people'], key=lambda k: (statList['people'][k]['qa']['1week']['regression']), reverse=True)
-    top10regression = []
-    for i in tmpClist:
-      if i != 'qa-admin at libreoffice.org' and i != 'libreoffice-commits at lists.freedesktop.org' and \
-        statList['people'][i]['qa']['1week']['regression'] > 0:
-        x = {'mail': i,
-             'name': statList['people'][i]['name'],
-             'week' :statList['people'][i]['qa']['1week']['regression'],
-             'month' :statList['people'][i]['qa']['1month']['regression'],
-             '3month':statList['people'][i]['qa']['3month']['regression']}
-        top10regression.append(x)
-        if len(top10regression) >= 10:
-          break
-
-    print("\n    + Done by:", file=fp)
-    xRow = []
-    for i in top10regression:
-      print('          {} added \'regression\' to {} bugs in 1 week, {} bugs in 1 month and {} bugs in 3 months'.format(
-            i['name'], i['week'], i['month'], i['3month']), file=fp)
-
-    tmpClist = sorted(statList['people'], key=lambda k: (statList['people'][k]['qa']['1week']['backtrace']), reverse=True)
-    top10backtrace = []
-    for i in tmpClist:
-      if i != 'qa-admin at libreoffice.org' and i != 'libreoffice-commits at lists.freedesktop.org' and \
-        statList['people'][i]['qa']['1week']['backtrace'] > 0:
-        x = {'mail': i,
-             'name': statList['people'][i]['name'],
-             'week' :statList['people'][i]['qa']['1week']['backtrace'],
-             'month' :statList['people'][i]['qa']['1month']['backtrace'],
-             '3month':statList['people'][i]['qa']['3month']['backtrace']}
-        top10backtrace.append(x)
-        if len(top10backtrace) >= 10:
-          break
-
-    print("\n    + Done by:", file=fp)
-    xRow = []
-    for i in top10backtrace:
-      print('          {} added a backtrace to {} bugs in 1 week, {} bugs in 1 month and {} bugs in 3 months'.format(
-            i['name'], i['week'], i['month'], i['3month']), file=fp)
-
+    print("\n    + top 10 contributors:", file=fp)
+    for i in range(0, 10):
+      print('          {} made {} changes in 1 month, and {} changes in 1 year'.format(
+            top10list[i]['mail'], top10list[i]['month'], top10list[i]['year']), file=fp)
     fp.close()
     return None
 
 
 
-def report_myfunc(statList, openhubData, gerritData, gitData, bugzillaData, cfg):
+def report_myfunc():
+   global statList, openhubData, gerritData, gitData, bugzillaData, cfg
 
    # {'title': 'mail from me', 'addr': 'my at own.home', 'file': '/tmp/myfile.txt'}
    return None
 
 
 
-def DUMP_report(cfg, statList) :
+def DUMP_report() :
+  global cfg, statList
   return
   tot = len(statList['list']['easyHacks_comments'])
   print('duming {} easyHacks with more than 5 comments:'.format(tot))
@@ -597,6 +463,7 @@ def DUMP_report(cfg, statList) :
 
 
 def runCfg(platform):
+    global cfg
     if 'esc_homedir' in os.environ:
       homeDir = os.environ['esc_homedir']
     else:
@@ -606,7 +473,7 @@ def runCfg(platform):
     cfg['platform'] = platform
     print("Reading and writing data to " + cfg['homedir'])
 
-    cfg['contributor'] = util_load_data_file(cfg['homedir'] + 'dump/developers_dump.json')
+    cfg['contributor'] = util_load_data_file(cfg['homedir'] + 'award.json')
     cfg['nowDate'] = datetime.datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
     cfg['cutDate'] = cfg['nowDate'] - datetime.timedelta(days=365)
     cfg['1weekDate'] = cfg['nowDate'] - datetime.timedelta(days=7)
@@ -617,7 +484,9 @@ def runCfg(platform):
 
 
 
-def runReport(cfg):
+def runReport():
+    global cfg, statList, openhubData, bugzillaData, gerritData, gitData
+
     statList = util_load_data_file(cfg['homedir'] + 'stats.json')
     openhubData = util_load_data_file(cfg['homedir'] + 'dump/openhub_dump.json')
     bugzillaData = util_load_data_file(cfg['homedir'] + 'dump/bugzilla_dump.json')
@@ -625,16 +494,16 @@ def runReport(cfg):
     gitData = util_load_data_file(cfg['homedir'] + 'dump/git_dump.json')
 
     xMail = []
-    x = report_mentoring(statList, openhubData, gerritData, gitData, bugzillaData, cfg)
+    x = report_mentoring()
     if not x is None:
       xMail.append(x)
-    x = report_ui(statList, openhubData, gerritData, gitData, bugzillaData, cfg)
+    x = report_ui()
     if not x is None:
       xMail.append(x)
-    x = report_qa(statList, openhubData, gerritData, gitData, bugzillaData, cfg)
+    x = report_qa()
     if not x is None:
       xMail.append(x)
-    x = report_myfunc(statList, openhubData, gerritData, gitData, bugzillaData, cfg)
+    x = report_myfunc()
     if not x is None:
       xMail.append(x)
 
@@ -648,4 +517,5 @@ def runReport(cfg):
 
 
 if __name__ == '__main__':
-    runReport(runCfg(sys.platform))
+    runCfg(sys.platform)
+    runReport()


More information about the Libreoffice-commits mailing list