[ckan-changes] commit/ckanext-stats: dread: [*]: #1143 Tweaks to visuals. Account for deleted packages. Added lots of tests. Moved stats.py from ckan to here.
Bitbucket
commits-noreply at bitbucket.org
Thu Jun 2 14:22:53 UTC 2011
1 new changeset in ckanext-stats:
http://bitbucket.org/okfn/ckanext-stats/changeset/bc54790cacd4/
changeset: bc54790cacd4
branches:
user: dread
date: 2011-06-02 16:22:45
summary: [*]: #1143 Tweaks to visuals. Account for deleted packages. Added lots of tests. Moved stats.py from ckan to here.
affected #: 8 files (23.2 KB)
--- a/README.txt Tue May 17 20:25:59 2011 +0100
+++ b/README.txt Thu Jun 02 15:22:45 2011 +0100
@@ -20,4 +20,4 @@
To run tests written for this extension::
pip -E pyenv install nose
- nosetests --ckan ckanext/stats/tests/
\ No newline at end of file
+ nosetests --ckan ../ckan/test.ini ckanext/stats/tests/
\ No newline at end of file
--- a/ckanext/stats/controller.py Tue May 17 20:25:59 2011 +0100
+++ b/ckanext/stats/controller.py Thu Jun 02 15:22:45 2011 +0100
@@ -1,18 +1,20 @@
from ckan.lib.base import BaseController, render, config
-import ckan.lib.stats
+import stats as stats_lib
class StatsController(BaseController):
def index(self):
from pylons import tmpl_context as c
- stats = ckan.lib.stats.Stats()
- rev_stats = ckan.lib.stats.RevisionStats()
+ stats = stats_lib.Stats()
+ rev_stats = stats_lib.RevisionStats()
c.top_rated_packages = stats.top_rated_packages()
c.most_edited_packages = stats.most_edited_packages()
c.largest_groups = stats.largest_groups()
c.top_tags = stats.top_tags()
c.top_package_owners = stats.top_package_owners()
c.new_packages_by_week = rev_stats.get_by_week('new_packages')
+ c.deleted_packages_by_week = rev_stats.get_by_week('deleted_packages')
+ c.num_packages_by_week = rev_stats.get_num_packages_by_week()
c.package_revisions_by_week = rev_stats.get_by_week('package_revisions')
return render('ckanext/stats/index.html')
--- a/ckanext/stats/templates/ckanext/stats/index.html Tue May 17 20:25:59 2011 +0100
+++ b/ckanext/stats/templates/ckanext/stats/index.html Thu Jun 02 15:22:45 2011 +0100
@@ -5,6 +5,8 @@
<py:def function="page_title">Statistics</py:def>
+ <py:def function="body_class">hide-sidebar</py:def>
+
<py:def function="optional_head"><!--[if IE]><script language="javascript" type="text/javascript" src="http://assets.okfn.org/ext/flot/0.6/excanvas.min.js"></script><![endif]--><script type="text/javascript" src="http://assets.okfn.org/ext/flot/0.6/jquery.flot.min.js">//pointless jscript comment</script>
@@ -20,11 +22,14 @@
xaxis: {
mode: "time",
timeformat: "%y-%b"
+ },
+ yaxis: {
+ min: 0
}
};
var data = [
[
- <py:for each="week_date, pkgs, num_packages, cumulative_num_packages in c.new_packages_by_week">
+ <py:for each="week_date, num_packages, cumulative_num_packages in c.num_packages_by_week">
[ new Date(${week_date.replace('-', ',')}), ${cumulative_num_packages} ],
</py:for>
]
@@ -34,6 +39,8 @@
<h3>Revisions to packages per week</h3><div id="package_revisions_graph" style="width:800px;height:300px"></div>
+ <h4>Legend:</h4>
+ <div id="legend" /><script type="text/javascript">
var options = {
xaxis: {
@@ -42,6 +49,7 @@
},
legend: {
position: "nw",
+ container: legend,
},
colors: ["#ffcc33", "#ff8844"]
};
@@ -69,12 +77,13 @@
</script><h3>Top Rated Packages</h3>
- <table>
+ <table py:if="c.top_rated_packages"><tr><th>Package</th><th>Average rating</th><th>Number of ratings</th></tr><tr py:for="package, rating, num_ratings in c.top_rated_packages"><td>${h.link_to(package.title or package.name, h.url_for(controller='package', action='read', id=package.name))}</td><td>${rating}</td><td>${num_ratings}</td></tr></table>
+ <p py:if="not c.top_rated_packages">No ratings</p><h3>Most Edited Packages</h3><table>
@@ -102,7 +111,7 @@
<h3>Users owning most packages</h3><table><tr py:for="user, num_packages in c.top_package_owners">
- <td>${user.name}</td><td>${num_packages}</td>
+ <td>${h.linked_user(user)}</td><td>${num_packages}</td></tr></table>
--- a/ckanext/stats/templates/ckanext/stats/leaderboard.html Tue May 17 20:25:59 2011 +0100
+++ b/ckanext/stats/templates/ckanext/stats/leaderboard.html Thu Jun 02 15:22:45 2011 +0100
@@ -5,6 +5,8 @@
<py:def function="page_title">Leaderboard - Stats</py:def>
+ <py:def function="body_class">hide-sidebar</py:def>
+
<py:def function="optional_head"><script type="text/javascript">
var solrCoreUrl = '${c.solr_core_url}';
--- a/ckanext/stats/tests/__init__.py Tue May 17 20:25:59 2011 +0100
+++ b/ckanext/stats/tests/__init__.py Thu Jun 02 15:22:45 2011 +0100
@@ -0,0 +1,13 @@
+from paste.deploy import appconfig
+import paste.fixture
+from ckan.config.middleware import make_app
+from ckan.tests import conf_dir, url_for
+
+class StatsFixture(object):
+
+ @classmethod
+ def setup_class(cls):
+ config = appconfig('config:test.ini', relative_to=conf_dir)
+ config.local_conf['ckan.plugins'] = 'stats'
+ wsgiapp = make_app(config.global_conf, **config.local_conf)
+ cls.app = paste.fixture.TestApp(wsgiapp)
--- a/ckanext/stats/tests/test_stats_plugin.py Tue May 17 20:25:59 2011 +0100
+++ b/ckanext/stats/tests/test_stats_plugin.py Thu Jun 02 15:22:45 2011 +0100
@@ -1,17 +1,10 @@
import os
-from paste.deploy import appconfig
-import paste.fixture
-from ckan.config.middleware import make_app
-from ckan.tests import conf_dir, url_for
-class TestStatsPlugin:
+from ckan.tests import url_for
- @classmethod
- def setup_class(cls):
- config = appconfig('config:test.ini', relative_to=conf_dir)
- config.local_conf['ckan.plugins'] = 'stats'
- wsgiapp = make_app(config.global_conf, **config.local_conf)
- cls.app = paste.fixture.TestApp(wsgiapp)
+from ckanext.stats.tests import StatsFixture
+
+class TestStatsPlugin(StatsFixture):
def test_01_config(self):
from pylons import config
Repository URL: https://bitbucket.org/okfn/ckanext-stats/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list