/soc/2012/sanket/www-statscollector: d3b8073eaca9: Add ``drilldo...

sanket sanket at soc.pidgin.im
Tue Jul 10 01:30:20 EDT 2012


Changeset: d3b8073eaca990d30cd97afda899a21ad96635e0
Author:	 sanket <sanket at soc.pidgin.im>
Date:	 2012-07-08 05:50 +0530
Branch:	 default
URL: http://hg.pidgin.im/soc/2012/sanket/www-statscollector/rev/d3b8073eaca9

Description:

Add ``drilldown'' on prpl-jabber

Prpl-jabber may consist of a Gtalk/Facebook account but the
username is not enough to distinguish. Hence we use Domain
or Connect-server to identify the same.

FIXME: Currently this is not very robust as gmail.com/mail.google.com
are identified separately

diffstat:

 pidgin_stats_collector/display/views.py             |  22 +++++-
 pidgin_stats_collector/media/js/charts.js           |  78 ++------------------
 pidgin_stats_collector/statscollector/models.py     |   1 +
 pidgin_stats_collector/statscollector/process.py    |  13 +++
 pidgin_stats_collector/templates/display/index.html |   6 +-
 5 files changed, 42 insertions(+), 78 deletions(-)

diffs (222 lines):

diff --git a/pidgin_stats_collector/display/views.py b/pidgin_stats_collector/display/views.py
--- a/pidgin_stats_collector/display/views.py
+++ b/pidgin_stats_collector/display/views.py
@@ -166,10 +166,26 @@
         annotate(Avg('buddies')).order_by('-buddies__avg')
 
     for item in account_count_dict:
-      stats_prpl_p[item['prpl_name']] = item['prpl_name__count']
+      stats_prpl_p[item['prpl_name']] = {}
+      stats_prpl_p[item['prpl_name']]['y'] = item['prpl_name__count']
+
     for item in account_avg_dict:
       stats_prpl_p_u[item['prpl_name']] = item['buddies__avg']
 
+    # IM user Jabber split up
+
+    jabber_service_dict = Account.objects.filter(prpl_name='prpl-jabber').\
+        values('service').annotate(Count('service')).order_by('-service__count')
+
+    stats_prpl_p['prpl-jabber']['drilldown'] = {}
+    stats_prpl_p['prpl-jabber']['drilldown']['name'] = 'Jabber Services'
+    stats_prpl_p['prpl-jabber']['drilldown']['categories'] = []
+    stats_prpl_p['prpl-jabber']['drilldown']['data'] = []
+
+    for item in jabber_service_dict:
+      stats_prpl_p['prpl-jabber']['drilldown']['categories'].append(item['service'])
+      stats_prpl_p['prpl-jabber']['drilldown']['data'].append(item['service__count'])
+
     # Plugins (3rd party/loadable-unloadable)
     plugin_count_dict = Plugin.objects.values('p_id').\
         annotate(Count('p_id')).order_by('-p_id__count')
@@ -276,8 +292,8 @@
       'arch_pie': simplejson.dumps(list(stats_dict[ARCH_NAME_STR].iteritems())),
       'purple_v_cat': simplejson.dumps(sorted_dict(stats_dict[PRPL_V_STR])[0]),
       'purple_v_dat': simplejson.dumps(sorted_dict(stats_dict[PRPL_V_STR])[1]),
-      'purple_p_cat': simplejson.dumps(sorted_dict(stats_dict[PRPL_P_STR])[0]),
-      'purple_p_dat': simplejson.dumps(sorted_dict(stats_dict[PRPL_P_STR])[1]),
+      'purple_p_cat': simplejson.dumps(stats_dict[PRPL_P_STR].keys()),
+      'purple_p_dat': simplejson.dumps(stats_dict[PRPL_P_STR].values()),
       'purple_p_u_cat': simplejson.dumps(sorted_dict(stats_dict[PRPL_P_U_STR])[0]),
       'purple_p_u_dat': simplejson.dumps(sorted_dict(stats_dict[PRPL_P_U_STR])[1]),
       'plugin_cat_top': \
diff --git a/pidgin_stats_collector/media/js/charts.js b/pidgin_stats_collector/media/js/charts.js
--- a/pidgin_stats_collector/media/js/charts.js
+++ b/pidgin_stats_collector/media/js/charts.js
@@ -1,63 +1,4 @@
-function drawChart(cat, dat, e, ttle) {
-    var chart;
-        chart = new Highcharts.Chart({
-            chart: {
-                renderTo: e,
-                type: 'column',
-                margin: [ 50, 50, 150, 80]
-            },
-            title: {
-                text: ttle
-            },
-            xAxis: {
-                categories: cat,
-                labels: {
-                    rotation: -45,
-                    align: 'right',
-                    style: {
-                        fontSize: '13px',
-                        fontFamily: 'Verdana, sans-serif'
-                    }
-                }
-            },
-            yAxis: {
-                min: 0,
-                title: {
-                    text: 'User count'
-                }
-            },
-            legend: {
-                enabled: true
-            },
-            tooltip: {
-                formatter: function() {
-                    return '<b>'+ this.x +'</b><br/>'+
-                        'User count: '+ this.y;
-                }
-            },
-                series: [{
-                name: 'Avg Buddy list size',
-                data: dat,
-                dataLabels: {
-                    enabled: true,
-                    rotation: 0,
-                    color: '#000',
-                    align: 'right',
-                    x: 0,
-                    y: -10,
-                    formatter: function() {
-                        return this.y;
-                    },
-                    style: {
-                        fontSize: '13px',
-                        fontFamily: 'Verdana, sans-serif'
-                    }
-                }	
-            }]
-        });
-  }
-  
- function drawPie(dat, e, ttle){
+function drawPie(dat, e, ttle){
     var chart;
     $(document).ready(function() {
         chart = new Highcharts.Chart({
@@ -99,7 +40,7 @@
     
 }
 
-function drawOSChart(cat, dat, e, title)
+function drawChart(cat, dat, e, title)
 	{
     var chart;
 
@@ -115,7 +56,7 @@
             chart.addSeries({
                 name: name,
                 data: data,
-                color: color || 'white'
+                color: color || '#4747FF'
             });
         }
     
@@ -125,10 +66,7 @@
                 type: 'column'
             },
             title: {
-                text: 'Operating System usage trend'
-            },
-            subtitle: {
-                text: 'Click the columns to view detailed OS analysis. Click again to come back.'
+                text: title
             },
             xAxis: {
                 categories: categories
@@ -168,11 +106,11 @@
             tooltip: {
                 formatter: function() {
                     var point = this.point,
-                        s = this.x +':<b>'+ this.y +'% market share</b><br/>';
+                        s = this.x +':<b>'+ this.y + '</b><br/>';
                     if (point.drilldown) {
-                        s += 'Click to view '+ point.category +' versions';
+                        s += 'Click to view more';
                     } else {
-                        s += 'Click to return to browser brands';
+                        s += 'Click to return';
                     }
                     return s;
                 }
@@ -180,7 +118,7 @@
             series: [{
                 name: name,
                 data: data,
-                color: 'white'
+                color: '#4747FF'
             }],
             exporting: {
                 enabled: false
diff --git a/pidgin_stats_collector/statscollector/models.py b/pidgin_stats_collector/statscollector/models.py
--- a/pidgin_stats_collector/statscollector/models.py
+++ b/pidgin_stats_collector/statscollector/models.py
@@ -22,6 +22,7 @@
   raw_xml = models.ForeignKey('RawXML')
   prpl_name = models.CharField(max_length=200)
   buddies = models.IntegerField()
+  service = models.CharField(max_length=200)
 
 class Plugin(models.Model):
 
diff --git a/pidgin_stats_collector/statscollector/process.py b/pidgin_stats_collector/statscollector/process.py
--- a/pidgin_stats_collector/statscollector/process.py
+++ b/pidgin_stats_collector/statscollector/process.py
@@ -108,9 +108,22 @@
 
       prpl_name = prpl_plugin.xpath('protocol')[0].text
       prpl_count=0
+      prpl_connect = None
+      prpl_domain  = None
       try:
         prpl_count = int(prpl_plugin.xpath('buddies')[0].text.strip())
       except: prpl_count = 0
+
+      # Determines the actual connect server in case of jabber protocol
+      try:
+        prpl_connect = prpl_plugin.xpath('connect-server')[0].text.strip()
+      except: pass
+      try:
+        prpl_domain = prpl_plugin.xpath('Domain')[0].text.strip()
+      except: pass
+      if prpl_connect: acc.service = prpl_connect
+      elif prpl_domain: acc.service = prpl_domain
+
       acc.prpl_name = prpl_name
       acc.buddies = prpl_count
 
diff --git a/pidgin_stats_collector/templates/display/index.html b/pidgin_stats_collector/templates/display/index.html
--- a/pidgin_stats_collector/templates/display/index.html
+++ b/pidgin_stats_collector/templates/display/index.html
@@ -176,16 +176,12 @@
       <br>
       </div>
     </div>
-  
-
-<!-- Scripts from Highcharts, I would prefer to pack them in a separate JS but for now this works! -->
-
 
 <script type="text/javascript"> <!-- Purple version information -->
 
 $(function (){
 
-	drawOSChart({{ os_name_cat|safe }}, {{ os_name_dat|safe }}, 'os-hc', 'Operating Systems');
+	drawChart({{ os_name_cat|safe }}, {{ os_name_dat|safe }}, 'os-hc', 'Operating Systems');
 	drawPie({{ arch_pie|safe }}, 'arch-pie', 'Architecture information');
 	drawChart({{ purple_v_cat|safe }}, {{ purple_v_dat|safe }}, 'purple-version', 'purple versions');
 	drawChart({{ plugin_cat_top|safe }}, {{ plugin_dat_top|safe }}, 'plugins', 'purple top plugins');



More information about the Commits mailing list