ckanext-googleanalytics_v2..../ckanext/googleanalytics/controller.py

24 lines
638 B
Python
Raw Normal View History

2011-04-04 18:44:39 +02:00
import logging
from ckan.lib.base import *
2011-04-04 18:44:39 +02:00
import dbutil
2011-04-04 18:44:39 +02:00
log = logging.getLogger('ckanext.googleanalytics')
class GAController(BaseController):
def view(self):
# get package objects corresponding to popular GA content
2011-04-04 18:44:39 +02:00
self.parse_ga_data()
c.top_packages = self.get_top_packages()
return render('index.html')
def __str__(self):
# XXX hack to provide consistent cache key; what's the
# canonical way of doing caching like this in CKAN right now?
return "analyticscontroller"
def get_top_packages(self):
2011-04-04 18:44:39 +02:00
items = dbutil.get_top_packages()
return items