Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merged all subjects into one column.

Also moved popular books/authors near subjects.
  • Loading branch information...
commit 05768a1a69f4b612e2fa9c3d6d84841b7702572a 1 parent 36f21d5
Anand Chitipothu anandology authored
12 openlibrary/solr/process_stats.py
View
@@ -142,10 +142,15 @@ def process(data):
"start_day_s":doc.t_start.split("T")[0],
}
+ solrdoc['subject_key'] = []
+ solrdoc['subject_facet'] = []
def add_subjects(type):
subjects = doc.get_subjects(type)
- solrdoc[type + '_key'] = [s.slug for s in subjects]
- solrdoc[type + '_facet'] = [s.title for s in subjects]
+ if type == 'subject':
+ system_subjects = ['protected_daisy', 'accessible_book', 'in_library', 'lending_library']
+ subjects = [s for s in subjects if s.slug not in system_subjects]
+ solrdoc['subject_key'] += [type+":"+s.slug for s in subjects]
+ solrdoc['subject_facet'] += [type+":"+s.title for s in subjects]
add_subjects("subject")
add_subjects("place")
@@ -192,5 +197,8 @@ def update_solr(docs):
fix_subject_key(doc, 'person_key', '/subjects/person:')
fix_subject_key(doc, 'time_key', '/subjects/time:')
+ system_subjects = ['subject:Protected DAISY', 'subject:Accessible book', 'subject:In library', 'subject:Lending library']
+ doc['subject_facet'] = [s for s in doc['subject_facet'] if s not in system_subjects]
+
solr.update(doc)
solr.commit()
24 openlibrary/templates/stats/lending.html
View
@@ -55,17 +55,22 @@ <h6 class="black collapse uppercase">$label</h6>
</div>
<div class="clearfix"></div>
+ <div>
+ $:render_counts("Popular Books", stats.get_facet_counts("book_key_s"), klass="contentHalf")
+ $:render_counts("Popular Authors", stats.get_facet_counts("author_keys_id"), klass="contentHalf")
+ </div>
+ <div class="clearfix"></div>
+ <br/>
+ <br/>
+
$if not stats.subject:
<div>
- $:render_counts("Subjects", stats.get_facet_counts("subject_facet"))
- <div class="contentSpacer"></div>
- $:render_counts("Places", stats.get_facet_counts("place_facet"))
- <div class="contentSpacer"></div>
- $:render_counts("People", stats.get_facet_counts("person_facet"))
- <div class="contentSpacer"></div>
- $:render_counts("Time", stats.get_facet_counts("time_facet"))
+ $:render_counts("Subjects", stats.get_facet_counts("subject_facet"), klass="")
</div>
<div class="clearfix"></div>
+ <br/>
+ <br/>
+
$if not stats.collection:
<div>
@@ -77,11 +82,6 @@ <h6 class="black collapse uppercase">$label</h6>
</div>
<div class="clearfix"></div>
- <div>
- $:render_counts("Popular Books", stats.get_facet_counts("book_key_s"), klass="contentHalf")
- $:render_counts("Popular Authors", stats.get_facet_counts("author_keys_id"), klass="contentHalf")
- </div>
- <div class="clearfix"></div>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.