diff --git a/r2/r2/lib/pages/graph.py b/r2/r2/lib/pages/graph.py index 9af3f4150..4d53dbce6 100644 --- a/r2/r2/lib/pages/graph.py +++ b/r2/r2/lib/pages/graph.py @@ -134,7 +134,7 @@ class LineGraph(object): google_api = "http://chart.apis.google.com/chart" def __init__(self, xydata, colors = ("FF4500", "336699"), - width = 350, height = 200): + width = 300, height = 175): series = zip(*xydata) diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index 10f635d0a..ae539b9c8 100644 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -1290,6 +1290,8 @@ class RedditTraffic(Traffic): "FF4500"), ("impressions", (1, 3) if c.site.domain else (1,), "336699")] + if not c.default_sr and ival == 'day': + slices.append(("subscriptions", (4,), "00FF00")) setattr(self, ival + "_data", data) for name, indx, color in slices: data2 = self.slice_traffic(data, *indx) diff --git a/r2/r2/templates/reddittraffic.html b/r2/r2/templates/reddittraffic.html index 33433c3ef..a6e826e63 100644 --- a/r2/r2/templates/reddittraffic.html +++ b/r2/r2/templates/reddittraffic.html @@ -26,42 +26,51 @@ return locale.format('%d', x, True) %> -

Traffic for ${c.site.name}

- - - -%if not thing.has_data: -

- ${_("There doesn't seem to be any traffic data at the moment. Please check back later.")} -

-%else: - - hourly uniques - hourly impressions -
- daily uniques - daily impressions - -
- - %if c.default_sr: - monthly uniques - monthly impressions - %endif - +<%def name="daily_summary()"> <% umin = min(data[0] for date, data in filter(None, thing.day_data)) umax = max(data[0] for date, data in filter(None, thing.day_data)) %> - -
+ + + %if c.site.domain: + + + + + + + + + + + %else: + + + + %if not c.default_sr: + + %endif + + %endif + + %for x, (date, data) in enumerate(reversed(thing.day_data)): + ${date.strftime("%Y-%m-%d")} + <% + indx = range(5) if c.site.domain else \ + [0,1,4] if not c.default_sr else [0,1] + %> + %for i in indx: + + %endfor + ${bars(data[0], data[1])} + + %endfor +
total${c.site.domain}
${_("date")}${_("uniques")}${_("impressions")}${_("uniques")}${_("impressions")}${_("subscriptions")}${_("date")}${_("uniques")}${_("impressions")}${_("subscriptions")}
${num(data[i]) if data[i] else "-"}
+ + +<%def name="weekly_summary()"> @@ -89,102 +98,116 @@
Weekly summary${num(int(thing.impressions_mean))}
- - - - %if c.site.domain: + + +

Traffic for ${c.site.name}

+ +%if not thing.has_data: +

+ ${_("There doesn't seem to be any traffic data at the moment. Please check back later.")} +

+%else: + +
+
+ hourly uniques +
+
+ daily uniques +
+ %if c.default_sr: +
+ monthly uniques +
+ %endif + ${weekly_summary()} + %if c.default_sr: + ${daily_summary()} + %endif +
+
+ hourly impressions +
+
+ daily impressions +
+ %if c.default_sr: +
+ monthly impressions +
+ <% data = thing.monthly_summary() %> +
+ + + + + + + + + %for i, d in enumerate(reversed(data)): + + %for cls, x in d: + + %endfor + + %endfor +
Monthly data
${_("date")}${_("uniques")}${_("impressions")}
${x}
+ + - - - - - - - - %else: - - - - %endif - - %for x, (date, data) in enumerate(reversed(thing.day_data)): - ${date.strftime("%Y-%m-%d")} - %for i in xrange(4 if c.site.domain else 2): - - %endfor - ${bars(data[0], data[1])} + - %endfor -
total${c.site.domain}
${_("date")}${_("uniques")}${_("impressions")}${_("uniques")}${_("impressions")}${_("date")}${_("uniques")}${_("impressions")}
${num(data[i]) if data[i] else "-"}${_("cnamed")}
-
- - %if c.default_sr: - <% data = thing.monthly_summary() %> - - - - - + - - %for i, d in enumerate(reversed(data)): - - %for cls, x in d: - - %endfor + + + - %endfor -
Monthly data
${_("date")} ${_("uniques")} ${_("impressions")}
${x}${_("uniques")}${_("impressions")}${_("cname")}
- - - - - - - - - - - - - - - - %for i, (sr, d) in enumerate(thing.reddits_summary()): - - - + + + %for x in d: + + %endfor + - %for x in d: - - %endfor - - - %endfor -
total${_("cnamed")}
${_("date")}${_("uniques")}${_("impressions")}${_("uniques")}${_("impressions")}${_("cname")}
- %if isinstance(sr, DomainSR): - [domain:${sr.name}] - %elif isinstance(sr, FakeSubreddit): - [meta:${sr.name}] - %else: - ${sr.name} + %for i, (sr, d) in enumerate(thing.reddits_summary()): +
+ %if isinstance(sr, DomainSR): + [domain:${sr.name}] + %elif isinstance(sr, FakeSubreddit): + [meta:${sr.name}] + %else: + ${sr.name} + %endif + + ${num(x) if x else "--"} + %if not isinstance(sr, FakeSubreddit) and sr.domain: + ${sr.domain} %endif - - ${num(x) if x else "--"} - %if not isinstance(sr, FakeSubreddit) and sr.domain: - ${sr.domain} - %endif -
- %endif + + + %endfor + + %else: + daily subscriptions + ${daily_summary()} + %endif %endif