community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject svn commit: r1681591 - /comdev/projects.apache.org/site/js/projects.js
Date Mon, 25 May 2015 14:52:49 GMT
Author: hboutemy
Date: Mon May 25 14:52:49 2015
New Revision: 1681591

URL: http://svn.apache.org/r1681591
Log:
use committees-retired.json instead of committees-evolution.json for rendering of better info

Modified:
    comdev/projects.apache.org/site/js/projects.js

Modified: comdev/projects.apache.org/site/js/projects.js
URL: http://svn.apache.org/viewvc/comdev/projects.apache.org/site/js/projects.js?rev=1681591&r1=1681590&r2=1681591&view=diff
==============================================================================
--- comdev/projects.apache.org/site/js/projects.js (original)
+++ comdev/projects.apache.org/site/js/projects.js Mon May 25 14:52:49 2015
@@ -19,9 +19,9 @@
 
 var people = {}; // committer -> name lookups
 var unixgroups = {}; // unix (ldap) groups (project -> committers lookup)
-var committees = {}; // id -> committee info (chair, established, group, homepage, id,
name, reporting, shortdesc)
+var committees = {}; // id -> committee info (chair, established, group, homepage, id,
name, reporting, shortdesc) (current committees)
 var committeesByName = {}; // name -> committee info
-var committeesEvolution = {}; // committees sorted by date founded, with retired (name =
"retired: name")
+var retiredCommittees = {}; // retired committees information: id -> committee info (established,
retired, homepage, id, name)
 var projects = {}; // Projects
 var evolution = {}; // Podling evolution
 
@@ -963,92 +963,31 @@ function isCommittee(name) {
 }
 
 // ------------ Front page rendering ------------\\
-function htmlListTooltip(date,name,values) {
-    return '<div style="padding:8px 8px 8px 8px;"><b>' + date + '</b>'
-	+ '<br/><b>' + values.length + '</b> ' + name + ((values.length > 1)
? 's:':':')
-	+ ((values.length > 0) ? '<br/>- '+values.join('<br/>- '):'')
-	+ '</div>';
-}
 
 function renderFrontPage() {
-    var numchairs = 0;
-    for (i in committees) numchairs++;
-    cur = evolution[0].current;
-    var nsubs = 0;
-    
+    var numcommittees = 0;
+    var i;
+    for (i in committees) numcommittees++;
+    var cur = evolution[0].current;
+
+    var nsubs = 0; // number of projects with DOAP that do not have same name than a committee
     for (i in projects) {
-	i = projects[i];
-	if (!i.name.match(/incubating/i)) {
-	    initiatives++;
-	    if (!isCommittee(i.name)) {
-		    nsubs++;
-	    }
-	}
+        i = projects[i];
+        if (i.pmc != 'incubator' && !isCommittee(i.name)) {
+            nsubs++;
+        }
     }
-    var initiatives = cur + numchairs + nsubs + 5; // podlings + committees + sub-projects
+ specials
+    var initiatives = cur + numcommittees + nsubs; // podlings + committees + sub-projects
     initiatives -= initiatives % 100; // round down
     var obj = document.getElementById('details');
     obj.innerHTML = "<h3 style='text-align: center;'>There are currently <span style='color:
#269;'>" + initiatives + "+</span> open source initatives at the ASF:</h3>"
-	+ "<ul style='width: 400px; margin: 0 auto; font-size: 18px; color: #269; font-weight:
bold;'>"
-    	+ "<li>" + numchairs + " committees managing " + (numchairs + nsubs) + " projects</li>"
-    	+ "<li>5 special committees*</li>"
-    	+ "<li>" + cur + " incubating podlings</li></ul>"
-    	+ "<p><small>*Infrastructure, Travel Assistance, Security Team, Legal Affairs
and Brand Management</small></p>";
-
-    var parr = [];
-    var cur = 0;
-    var karr = [];
-    for (i in committeesEvolution) {
-	karr.push(i);
-    }
-    karr.sort();
-    
-    for (var j in karr) {
-        var i = karr[j];
-        var changes = committeesEvolution[i];
-        var newCommittees = [];
-        var retiredCommittees = [];
-        for (var k in changes) {
-            var change = changes[k];
-            if (change.match(/retired: /)) {
-                retiredCommittees.push(change.substring(9))
-            } else {
-                newCommittees.push(change)
-            }
-        }
-        cur += newCommittees.length - retiredCommittees.length;
-        parr.push([i, newCommittees.length, htmlListTooltip(i, 'new committee', newCommittees),
retiredCommittees.length, htmlListTooltip(i, 'retired committee', retiredCommittees), cur]);
-    }
-    //narr.sort(function(a,b) { return (b[1] - a[1]) });
-    var data1 = new google.visualization.DataTable();
-    data1.addColumn('string', 'Month');
-    data1.addColumn('number', "New committees");
-    data1.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});
-    data1.addColumn('number', "Retired committees");
-    data1.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});
-    data1.addColumn('number', 'Current committees');
+        + "<ul style='width: 400px; margin: 0 auto; font-size: 18px; color: #269; font-weight:
bold;'>"
+        + "<li>" + numcommittees + " committees managing " + (numcommittees + nsubs)
+ " projects</li>"
+        + "<li>5 special committees*</li>"
+        + "<li>" + cur + " incubating podlings</li></ul>"
+        + "<p><small>*Infrastructure, Travel Assistance, Security Team, Legal
Affairs and Brand Management</small></p>";
 
-    data1.addRows(parr);
-
-    coptions = {
-	title: "Committee evolution",
-	isStacked: true,
-	height: 320,
-	width: 1160,
-	seriesType: "bars",
-	backgroundColor: 'transparent',
-	series: {2: {type: "line", targetAxisIndex: 1}},
-	tooltip: {isHtml: true},
-	vAxes:[
-              {title: 'Change in states'},
-              {title: 'Current number of committees'}
-              ]
-    };
-    var div = document.createElement('div');
-    obj.appendChild(div);
-    chart = new google.visualization.ComboChart(div);
-    chart.draw(data1, coptions);
-    
+    renderCommitteeEvolution();
     
     var earr = [];
     for (i in evolution) {
@@ -1080,7 +1019,7 @@ function renderFrontPage() {
               {title: 'Current number of podlings'}
               ]
     };
-    div = document.createElement('div');
+    var div = document.createElement('div');
     obj.appendChild(div);
     chart = new google.visualization.ComboChart(div);
     chart.draw(data, coptions);
@@ -1091,6 +1030,85 @@ function renderFrontPage() {
 
 // ------------ Chart functions ------------\\
 
+function htmlListTooltip(date,name,values) {
+    return '<div style="padding:8px 8px 8px 8px;"><b>' + date + '</b>'
+        + '<br/><b>' + values.length + '</b> ' + name + ((values.length
> 1) ? 's:':':')
+        + ((values.length > 0) ? '<br/>- '+values.join('<br/>- '):'')
+        + '</div>';
+}
+
+function renderCommitteeEvolution() {
+    var evo = {}; // 'year-month' -> { established: [], retired: [] }
+    var maxYear = new Date().getFullYear();
+    for (var year = 1995; year <= maxYear; year++) {
+        var maxMonth = (year < maxYear) ? 12 : (new Date().getMonth() + 1);
+        for (var month = 1; month <= maxMonth; month++) {
+            var key = year + '-' + (month < 10 ? '0':'') + month;
+            evo[key] = { 'established': [], 'retired': [] };
+        }
+    }
+    // add current committees
+    var c;
+    for (c in committees) {
+        c = committees[c];
+        evo[c.established]['established'].push(c);
+    }
+    // add retired committees
+    for (c in retiredCommittees) {
+        c = retiredCommittees[c];
+        evo[c.established]['established'].push(c);
+        evo[c.retired]['retired'].push(c);
+    }
+
+    var data = [];
+    var cur = 0;
+    var d;
+    for (d in evo) {
+        var established = evo[d]['established'];
+        var retired = evo[d]['retired'];
+        var estDisplay = [];
+        for (c in established) {
+            c = established[c];
+            estDisplay.push(c.name + ((c.id in retiredCommittees) ? ' (retired ' + retiredCommittees[c.id]['retired']
+ ')':''));
+        }
+        var retDisplay = [];
+        for (c in retired) {
+            c = retired[c];
+            retDisplay.push(c.name + ' (established ' + c['established'] + ')');
+        }
+        cur += established.length - retired.length;
+        data.push([d, established.length, htmlListTooltip(d, 'new committee', estDisplay),
retired.length, htmlListTooltip(d, 'retired committee', retDisplay), cur]);
+    }
+    //narr.sort(function(a,b) { return (b[1] - a[1]) });
+    var dataTable = new google.visualization.DataTable();
+    dataTable.addColumn('string', 'Month');
+    dataTable.addColumn('number', "New committees");
+    dataTable.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});
+    dataTable.addColumn('number', "Retired committees");
+    dataTable.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});
+    dataTable.addColumn('number', 'Current committees');
+
+    dataTable.addRows(data);
+
+    var options = {
+        title: "Committee evolution",
+        isStacked: true,
+        height: 320,
+        width: 1160,
+        seriesType: "bars",
+        backgroundColor: 'transparent',
+        series: {2: {type: "line", targetAxisIndex: 1}},
+        tooltip: {isHtml: true},
+        vAxes:[
+            {title: 'Change in states'},
+            {title: 'Current number of committees'}
+        ]
+    };
+    var div = document.createElement('div');
+    document.getElementById('details').appendChild(div);
+    var chart = new google.visualization.ComboChart(div);
+    chart.draw(dataTable, options);
+}
 
 function renderLanguageChart() {
     var obj = document.getElementById('contents');
@@ -1100,11 +1118,11 @@ function renderLanguageChart() {
     // Languages
     var lingos = [];
     var lcount = {};
-    for (i in projects) {
+    for (var i in projects) {
         i = projects[i];
 	if (i['programming-language']) {
 	    var a = i['programming-language'].split(", ");
-	    for (x in a) {
+	    for (var x in a) {
                 x = a[x];
 		if (lingos.indexOf(x) < 0) {
 		    lingos.push(x);
@@ -1116,7 +1134,7 @@ function renderLanguageChart() {
     }
     
     
-    narr = [];
+    var narr = [];
     for (i in lingos) {
 	var lang = lingos[i];
 	narr.push([lang, lcount[lang], 'Click here to view all projects using ' + lang]);
@@ -1167,7 +1185,7 @@ function renderLanguageChart() {
     }
     
     
-    carr = [];
+    var carr = [];
     for (i in cats) {
 	var cat = cats[i];
 	carr.push([cat, ccount[cat], 'Click here to view all projects in the ' + cat + ' category'])
@@ -1201,8 +1219,6 @@ function renderLanguageChart() {
     }
     google.visualization.events.addListener(chart2, 'select', selectHandlerCategory);
     chart2.draw(data2, options);
-    
-
 }
 
 function buildFrontPage() {
@@ -1337,24 +1353,28 @@ function checkKeyPress(e, txt) {
 
 // ------------ Weave functions ------------\\
 
-// Add projects if they aren't in the hash already
+function weaveById(list,mapById) {
+    for (var i in list) {
+        var o = list[i];
+        mapById[o.id] = o;
+    }
+}
+
+// Add content by id to projects
 function weaveInProjects(json) {
     for (p in json) {
-        if (!projects[p]) {
-                if (json[p].category) {
-                    // temporary hack: json are now generated without the http://projects.apache.org/category/
url
-                    json[p].category = json[p].category.replace(new RegExp("http://projects.apache.org/category/",
'g'), '');
-                }
-            projects[p] = json[p];
-        }
+        projects[p] = json[p];
     }
 }
 
+function weaveInRetiredCommittees(json) {
+    weaveById(json, retiredCommittees);
+}
+
 function setCommittees(json, state) {
+    weaveById(json, committees);
     for (p in json) {
         p = json[p];
-        // committees = { id -> committee }
-        committees[p.id] = p;
         // committeesByName = { name -> committee }
         committeesByName[p.name] = p;
     }
@@ -1416,7 +1436,7 @@ function preloadEverything(callback) {
         ["json/foundation/people_name.json", "people", function(json) { people = json; }],
         ["json/foundation/projects.json", "projects", weaveInProjects],
         ["json/foundation/podlings.json", "podlings", weaveInProjects],
-        ["json/foundation/committees-evolution.json", "committees evolution", function(json)
{ committeesEvolution = json; }],
+        ["json/foundation/committees-retired.json", "retired committees", weaveInRetiredCommittees],
         ["json/foundation/podlings-evolution.json", "podlings evolution", function(json)
{ evolution = json; }]
         ],
 	callback);



Mime
View raw message