[Groonga-commit] ranguba/epub-searcher at cd06405 [master] Drilldown by author

Back to archive index

KITAITI Makoto null+****@clear*****
Fri Sep 18 18:21:03 JST 2015


KITAITI Makoto	2015-09-18 18:21:03 +0900 (Fri, 18 Sep 2015)

  New Revision: cd0640531cc5b1a2c096cd4bf40d1702f31d8e81
  https://github.com/ranguba/epub-searcher/commit/cd0640531cc5b1a2c096cd4bf40d1702f31d8e81

  Message:
    Drilldown by author

  Modified files:
    app/app.rb
    app/controllers/main-controller.rb
    app/views/books.haml
    app/views/index.haml

  Modified: app/app.rb (+19 -2)
===================================================================
--- app/app.rb    2015-09-18 18:20:41 +0900 (6117552)
+++ app/app.rb    2015-09-18 18:21:03 +0900 (6a72ed3)
@@ -64,7 +64,9 @@ module EPUBSearcher
           :table => :Books,
           :query => query_words,
           :match_columns => 'author,title,main_text',
-          :output_columns => 'author,title,snippet_html(main_text)'
+          :output_columns => 'author,title,snippet_html(main_text)',
+          :drilldown => 'author',
+          :drilldown_output_columns => '_key,_nsubrecs'
         )
       ensure
         db.close
@@ -75,7 +77,22 @@ module EPUBSearcher
       begin
         db.select(
           :table => :Books,
-          :output_columns => '_id,author,title,file_path'
+          :output_columns => '_id,author,title,file_path',
+          :drilldown => 'author',
+          :drilldown_output_columns => '_key,_nsubrecs'
+        )
+      ensure
+        db.close
+      end
+    end
+
+    def author_drilldowns_from_groonga
+      begin
+        db.select(
+          :table => :Books,
+          :drilldown => 'author',
+          :drilldown_output_columns => '_key,_nsubrecs',
+          :limit => 0
         )
       ensure
         db.close

  Modified: app/controllers/main-controller.rb (+8 -2)
===================================================================
--- app/controllers/main-controller.rb    2015-09-18 18:20:41 +0900 (718051d)
+++ app/controllers/main-controller.rb    2015-09-18 18:21:03 +0900 (fe487c9)
@@ -6,14 +6,20 @@ EPUBSearcher::App.controllers do
 
     right_query = @query_words && !@query_words.empty?
     if right_query
-      @results = search_from_groonga(@query_words).records
+      results = search_from_groonga(@query_words)
+      @results = results.records
+      @drilldowns = results.drilldowns
+    else
+      @drilldowns = author_drilldowns_from_groonga.drilldowns
     end
 
     render 'index'
   end
 
   get :books do
-    @books = books_from_groonga.records
+    results = books_from_groonga
+    @books = results.records
+    @drilldowns = results.drilldowns
 
     render 'books'
   end

  Modified: app/views/books.haml (+2 -0)
===================================================================
--- app/views/books.haml    2015-09-18 18:20:41 +0900 (deb3da5)
+++ app/views/books.haml    2015-09-18 18:21:03 +0900 (946151c)
@@ -1,6 +1,8 @@
 - content_for(:title) {t('books.title')}
 %div{:class => 'container'}
 
+  = partial 'authors_drilldown'
+
   %div{:class => 'page-header'}
     %h1= link_to t('books.title'), url_for(:books)
 

  Modified: app/views/index.haml (+2 -0)
===================================================================
--- app/views/index.haml    2015-09-18 18:20:41 +0900 (4e0373e)
+++ app/views/index.haml    2015-09-18 18:21:03 +0900 (e2a95da)
@@ -1,6 +1,8 @@
 - content_for(:title) {t('search_results', query_words: @query_words)} if @results
 %div{:class => 'container'}
 
+  = partial 'authors_drilldown'
+
   %div{:class => 'page-header'}
     %h2= link_to 'EPUB Searcher', url_for(:index)
     %h1= t'search_results', query_words: @query_words if @results
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index