Only show the months for Downloads that we have
Only show the months for Downloads that we have

--- a/ckanext/ga_report/controller.py
+++ b/ckanext/ga_report/controller.py
@@ -21,7 +21,7 @@
     return '%s %s' % (calendar.month_name[d.tm_mon], d.tm_year)
 
 
-def _month_details(cls):
+def _month_details(cls, stat_key=None):
     '''
     Returns a list of all the periods for which we have data, unfortunately
     knows too much about the type of the cls being passed as GA_Url has a
@@ -32,9 +32,12 @@
     months = []
     day = None
 
-    vals = model.Session.query(cls.period_name,cls.period_complete_day)\
-        .filter(cls.period_name!='All').distinct(cls.period_name)\
-        .order_by("period_name desc").all()
+    q = model.Session.query(cls.period_name,cls.period_complete_day)\
+        .filter(cls.period_name!='All').distinct(cls.period_name)
+    if stat_key:
+        q=  q.filter(cls.stat_name==stat_key)
+
+    vals = q.order_by("period_name desc").all()
     if vals and vals[0][1]:
         day = int(vals[0][1])
         ordinal = 'th' if 11 <= day <= 13 \
@@ -203,7 +206,7 @@
 
         # Get the month details by fetching distinct values and determining the
         # month names from the values.
-        c.months, c.day = _month_details(GA_Stat)
+        c.months, c.day = _month_details(GA_Stat, "Downloads")
 
         # Work out which month to show, based on query params of the first item
         c.month_desc = 'all months'
@@ -223,9 +226,7 @@
                 continue
             data[r] += int(entry.value)
 
-        for k,v in data.iteritems():
-            c.downloads.append((k,v))
-
+        c.downloads = [(k,v,) for k,v in data.iteritems()]
         c.downloads = sorted(c.downloads, key=operator.itemgetter(1), reverse=True)
 
         return render('ga_report/site/downloads.html')

--- a/ckanext/ga_report/download_analytics.py
+++ b/ckanext/ga_report/download_analytics.py
@@ -307,7 +307,7 @@
         if not result_data:
             # We may not have data for this time period, so we need to bail
             # early.
-            log.info("There is no downloads data for this time period")
+            log.info("There is no download data for this time period")
             return
 
         # [[url, count], [url],count]

--- a/ckanext/ga_report/templates/ga_report/ga_util.html
+++ b/ckanext/ga_report/templates/ga_report/ga_util.html
@@ -46,7 +46,7 @@
 
 <table py:def="downloads_table(items)" class="table table-condensed table-bordered table-striped">
     <tr>
-        <th>Name</th>
+        <th>Dataset and resource</th>
         <th>Downloads</th>
     </tr>
     <py:for each="resource, value in items">