[releng] health: add a new wanted-releases.html experiment



commit 5ec04ca0ec0eb610bd5a6b930d029e4d310c6e5d
Author: Frédéric Péters <fpeters 0d be>
Date:   Wed Nov 25 21:32:39 2015 +0100

    health: add a new wanted-releases.html experiment

 tools/health/health.py            |   45 +++++++++++-
 tools/health/wanted-releases.html |  143 +++++++++++++++++++++++++++++++++++++
 2 files changed, 187 insertions(+), 1 deletions(-)
---
diff --git a/tools/health/health.py b/tools/health/health.py
index 5653c13..34a1179 100644
--- a/tools/health/health.py
+++ b/tools/health/health.py
@@ -154,6 +154,36 @@ class Commit:
         d['date'] = datetime.datetime.strftime(d['date'], '%Y-%m-%d %H:%M')
         return d
 
+def get_recent_tag_info(cwd):
+    cmd = ['git', 'describe', '--tags', '--long']
+    p = subprocess.Popen(cmd,
+            close_fds=True,
+            stdin=None,
+            stdout=subprocess.PIPE,
+            stderr=None,
+            cwd=cwd)
+    tagname, nb_commits, commit_id = str(p.stdout.read(), 'ascii').strip().rsplit('-', 2)
+
+    cmd = ['git', 'show', tagname]
+    p = subprocess.Popen(cmd,
+            close_fds=True,
+            stdin=None,
+            stdout=subprocess.PIPE,
+            stderr=None,
+            cwd=cwd)
+    commit_id = None
+    for line in p.stdout.readlines():
+        line = str(line, 'ascii', 'ignore')
+        if line.startswith('commit '):
+            commit_id = line.strip().split(' ')[1]
+            break
+
+    return {
+            'most_recent_tag': tagname,
+            'commits_since_most_recent_tag': int(nb_commits),
+            'most_recent_tag_commit_id': commit_id,
+            }
+
 def get_git_log(cwd):
     cmd = ['git', 'log', '--stat', '--date=short', '--format=fuller']
     p = subprocess.Popen(cmd,
@@ -165,7 +195,7 @@ def get_git_log(cwd):
     current_commit = None
     logs = []
     for line in p.stdout:
-        line = str(line, 'utf-8')
+        line = str(line, 'utf-8', 'replace')
         if line.startswith('commit '):
             if current_commit:
                 yield current_commit
@@ -207,12 +237,22 @@ def pick_git_infos():
             json.dump([x.to_dict() for x in git_log],
                     open(os.path.join(CACHE_DIR, 'git', '%s.json' % module), 'w'))
         modules[module]['git'] = {}
+        modules[module]['git'].update(get_recent_tag_info(
+            cwd=os.path.join(GIT_REPOSITORIES_DIR, module)))
         most_recent_commit = [x for x in git_log if not x.translation_commit][0]
         modules[module]['git']['most_recent_commit'] = most_recent_commit.date.strftime('%Y-%m-%d')
         modules[module]['git']['first_commit'] = git_log[-1].date.strftime('%Y-%m-%d')
         one_year_ago = datetime.datetime.now() - datetime.timedelta(days=365)
         modules[module]['git']['commits_in_12m'] = len(
                 [x for x in git_log if x.date > one_year_ago])
+        if modules[module]['git'].get('most_recent_tag'):
+            most_recent_tag_commit_id = modules[module]['git']['most_recent_tag_commit_id']
+            most_recent_tag_commit = [x for x in git_log if x.id.startswith(most_recent_tag_commit_id)]
+            if most_recent_commit:
+                commits = [x for x in git_log[:git_log.index(most_recent_tag_commit[0])]]
+                modules[module]['git']['non_translation_commits_since_most_recent_tag'] = len(
+                    [x for x in commits if not x.translation_commit])
+
         committers = {}
         authors = {}
         maintainers = {}
@@ -261,7 +301,10 @@ def pick_git_infos():
 
 
 if __name__ == '__main__':
+    print('pick_moduleset_infos')
     pick_moduleset_infos()
+    print('pick_doap_infos')
     pick_doap_infos()
+    print('pick_git_infos')
     pick_git_infos()
     json.dump(list(modules.values()), open('data.json', 'w'), indent=2)
diff --git a/tools/health/wanted-releases.html b/tools/health/wanted-releases.html
new file mode 100644
index 0000000..847fc9a
--- /dev/null
+++ b/tools/health/wanted-releases.html
@@ -0,0 +1,143 @@
+<!DOCTYPE>
+<html>
+<head>
+<title>Wanted Releases</title>
+<script src="js/jquery-latest.js"></script>
+<style>
+body { font-family: sans-serif; font-size: 10px; color: #333;}
+
+span { font-size: 10px; font-weight: normal; }
+
+div.prio0 {
+        font-size: 80%;
+}
+
+h1, h2 { display: inline-block; padding-right: 1em; }
+
+h2.prio0 { color: #ccc; font-weight: normal; }
+h2.prio1 { color: #f99; }
+h2.prio2 { color: #f66; }
+h2.prio3 { color: #f33; }
+h2.prio3 { color: #f00; }
+h2.prio4 { color: #f00; font-size: 110%; }
+
+</style>
+</head>
+<body>
+<div class="legend">(numbers are numbers of commits since last tag, first number
+       omits the translation commits)</div>
+
+<script>
+var by_maintainers = Object();
+$(document).ready(function() {
+  jQuery.getJSON('data.json', function(data, status, xhr) {
+    $(data).each(function(idx, value) {
+       if (value.doap_error) return;
+       if (typeof(value.git) === 'undefined') return;
+       $.map(value.maintainers, function(o, i) {
+         if (o.commits_in_12m > 0) {
+           if (typeof(by_maintainers[o.name]) === 'undefined') {
+             by_maintainers[o.name] = Array();
+           }
+           by_maintainers[o.name].push(value);
+           by_maintainers[o.name].sort(function(x, y) { return x.module.localeCompare(y.module); });
+         }
+       });
+    })
+    sorted_maintainers = Object.keys(by_maintainers);
+    sorted_maintainers.sort();
+    $(sorted_maintainers).each(function(idx, value) {
+      var div = $('<div>');
+      $('<h1>' + value + '</h1>').appendTo(div);
+      $(by_maintainers[value]).each(function(idx, value) {
+        var h2 = $('<h2>' + value.module + ' </h2>').appendTo(div);
+        var nb_commits = parseInt(value.git.commits_since_most_recent_tag);
+        var nb_non_translation_commits = parseInt(value.git.non_translation_commits_since_most_recent_tag);
+        $('<span class="nb">' + nb_non_translation_commits + ' / ' + nb_commits + '</span>').appendTo(h2);
+        max_prio = 0;
+        if (nb_commits < 5 || nb_non_translation_commits < 5) {
+           $(h2).attr('class', 'prio0');
+        } else if (nb_commits < 15 || nb_non_translation_commits < 15) {
+           $(h2).attr('class', 'prio1');
+           max_prio = Math.max(max_prio, 1);
+        } else if (nb_commits < 30 || nb_non_translation_commits < 30) {
+           $(h2).attr('class', 'prio2');
+           max_prio = Math.max(max_prio, 2);
+        } else if (nb_commits < 60 || nb_non_translation_commits < 60) {
+           $(h2).attr('class', 'prio3');
+           max_prio = Math.max(max_prio, 3);
+        } else {
+           $(h2).attr('class', 'prio4');
+           max_prio = Math.max(max_prio, 4);
+        }
+        $(div).attr('class', 'prio' + max_prio);
+      });
+      $(div).appendTo($('body'));
+    });
+  });
+/*
+  $(Object.keys(by_maintainers))
+       $('<td>' + value.jhbuild_category + '</td>').appendTo(row);
+       $('<td>' + value.module + '</td>').appendTo(row);
+       $('<td>' + value.shortdesc + '</td>').appendTo(row);
+       $('<td>' + $.map(value.maintainers, function(o, i) {
+         if (o.commits_in_12m == 0) {
+           return '<span class="inactive">' + o.name + '</span>';
+         } else {
+           return o.name;
+         }
+       }).join(", ") + '</td>').appendTo(row);
+       if (value.programminglanguage) {
+         $('<td>' + value.programminglanguage + '</td>').appendTo(row);
+       } else if (value.git.language) {
+         $('<td>' + value.git.language + ' (guess)</td>').appendTo(row);
+       } else {
+         $('<td></td>').appendTo(row);
+       }
+       code_repos_score = 0;
+       if (value.git.commits_in_12m == 0) {
+         code_repos_score += 5;
+       } else if (value.git.commits_in_12m < 5) {
+         code_repos_score += 2;
+       } else if (value.git.commits_in_12m < 20) {
+         code_repos_score += 1;
+       }
+       if (value.git.committers_in_12m == 1) {
+         code_repos_score += 3;
+       } else if (value.git.committers_in_12m == 2) {
+         code_repos_score += 1;
+       }
+       number_of_maintainers = value.maintainers.length;
+       if (number_of_maintainers == 0) {
+         code_repos_score += 2;
+       } else if (number_of_maintainers == 1) {
+         code_repos_score += 1;
+       }
+
+       inactive_maintainers = Array();
+       for (i = 0; i < value.maintainers.length; i++) {
+         maintainer = value.maintainers[i];
+         if (maintainer.commits_in_12m == 0) {
+           inactive_maintainers.push(maintainer);
+         }
+       }
+       if (inactive_maintainers.length == value.maintainers.length) {
+         code_repos_score += 2;
+       } else if (inactive_maintainers.length > 0) {
+         code_repos_score += 1;
+       }
+
+       if (value.git.committers_in_12m == value.git.authors_in_12m) {
+         code_repos_score += 1;
+       }
+
+       $('<td>' + code_repos_score + '</td>').appendTo(row);
+       $(row).appendTo($('tbody'));
+    });
+  });
+  */
+});
+</script>
+</body>
+</html>
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]