2011-04-04 18:44:39 +02:00
|
|
|
import logging
|
2011-02-11 12:21:19 +01:00
|
|
|
from ckan.lib.base import *
|
2011-04-04 18:44:39 +02:00
|
|
|
import dbutil
|
2011-02-11 12:21:19 +01:00
|
|
|
|
2011-04-04 18:44:39 +02:00
|
|
|
|
|
|
|
log = logging.getLogger('ckanext.googleanalytics')
|
2011-02-11 12:21:19 +01:00
|
|
|
|
|
|
|
|
|
|
|
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()
|
2011-02-11 12:21:19 +01:00
|
|
|
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?
|
2011-02-28 19:10:11 +01:00
|
|
|
return "analyticscontroller"
|
2011-02-11 12:21:19 +01:00
|
|
|
|
|
|
|
def get_top_packages(self):
|
2011-04-04 18:44:39 +02:00
|
|
|
items = dbutil.get_top_packages()
|
2011-02-11 12:21:19 +01:00
|
|
|
return items
|