Skip to content

Commit

Permalink
Added popular books.
Browse files Browse the repository at this point in the history
  • Loading branch information
Anand Chitipothu committed Dec 5, 2013
1 parent 1c1ba5c commit ad79f15
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions openlibrary/core/loanstats.py
Expand Up @@ -85,6 +85,7 @@ def _get_all_facet_counts(self):
facets = [
"library_s","region_s",
"ia_collections_id", "sponsor_s", "contributor_s",
"book_key_s",
"subject_facet", "place_facet", "person_facet", "time_facet"]

params = {
Expand Down Expand Up @@ -130,6 +131,11 @@ def make_facet(self, name, key, count):
elif name == "region_s":
title = key.upper()
slug = key
elif name == "book_key_s":
# XXX-Anand: Optimize this by pre loading all books
book = web.ctx.site.get(key)
title = book and book.title or "untitled"
slug = key
elif name in ["subject_facet", "person_facet", "place_facet", "time_facet"]:
title = key

Expand Down
9 changes: 8 additions & 1 deletion openlibrary/templates/stats/lending.html
Expand Up @@ -13,7 +13,7 @@ <h1><a href="/stats/lending">Lending Stats</a> / Subjects / $stats.subject</h1>
<h1>Lending Stats</h1>
</div>

$ facet_urls = {"libraries": "/stats/lending/libraries/%(slug)s", "regions": "/stats/lending/regions/%(slug)s", "collections": "/stats/lending/collections/%(slug)s", "subjects": "/stats/lending/subjects/%(slug)s", "places": "/stats/lending/subjects/place:%(slug)s", "people": "/stats/lending/subjects/person:%(slug)s", "time": "/stats/lending/subjects/time:%(slug)s"}
$ facet_urls = {"libraries": "/stats/lending/libraries/%(slug)s", "regions": "/stats/lending/regions/%(slug)s", "collections": "/stats/lending/collections/%(slug)s", "subjects": "/stats/lending/subjects/%(slug)s", "places": "/stats/lending/subjects/place:%(slug)s", "people": "/stats/lending/subjects/person:%(slug)s", "time": "/stats/lending/subjects/time:%(slug)s", "popular books": "%(slug)s"}

$def render_counts(label, counts, klass="contentQuarter"):
<div class="$klass">
Expand Down Expand Up @@ -65,6 +65,13 @@ <h2>Loans Per Day</h2>
$:render_counts("Contributor", stats.get_facet_counts("contributor_s"))
</div>
<div class="clearfix"></div>

<div>
$:render_counts("Popular Books", stats.get_facet_counts("book_key_s"), klass="")
</div>
<div class="clearfix"></div>


</div>

<script type="text/javascript">
Expand Down

0 comments on commit ad79f15

Please sign in to comment.