[Groonga-commit] groonga/groonga-command at f8d0afb [master] select: support drilldown_filter and drilldowns[LABEL].filter

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Mar 27 12:02:27 JST 2017


Kouhei Sutou	2017-03-27 12:02:27 +0900 (Mon, 27 Mar 2017)

  New Revision: f8d0afbd04abc30fc635582eaf48810ae558cda6
  https://github.com/groonga/groonga-command/commit/f8d0afbd04abc30fc635582eaf48810ae558cda6

  Message:
    select: support drilldown_filter and drilldowns[LABEL].filter

  Modified files:
    lib/groonga/command/select.rb
    test/command/test-select.rb

  Modified: lib/groonga/command/select.rb (+12 -1)
===================================================================
--- lib/groonga/command/select.rb    2017-01-18 09:56:44 +0900 (3ef258d)
+++ lib/groonga/command/select.rb    2017-03-27 12:02:27 +0900 (f470bc5)
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2016  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2012-2017  Kouhei Sutou <kou �� clear-code.com>
 # Copyright (C) 2016  Masafumi Yokoyama <yokoyama �� clear-code.com>
 #
 # This library is free software; you can redistribute it and/or
@@ -49,6 +49,7 @@ module Groonga
             :adjuster,
             :drilldown_calc_types,
             :drilldown_calc_target,
+            :drilldown_filter,
             :sort_keys,
             :drilldown_sort_keys,
           ]
@@ -92,6 +93,13 @@ module Groonga
         @drilldowns ||= array_value(:drilldown)
       end
 
+      # @return [String, nil] The filter for the drilled down result.
+      #
+      # @since 1.3.3
+      def drilldown_filter
+        self[:drilldown_filter]
+      end
+
       # @return [::Array<String>] The sort keys for drilldowns.
       #
       # @since 1.2.8
@@ -156,6 +164,7 @@ module Groonga
           limit = parse_integer_value(raw_drilldown["limit"])
           calc_types = parse_array_value(raw_drilldown["calc_types"])
           calc_target = raw_drilldown["calc_target"]
+          filter = raw_drilldown["filter"]
           drilldown = Drilldown.new(keys,
                                     sort_keys,
                                     output_columns,
@@ -163,6 +172,7 @@ module Groonga
                                     limit,
                                     calc_types,
                                     calc_target,
+                                    filter,
                                     label)
           labeled_drilldowns[label] = drilldown
         end
@@ -216,6 +226,7 @@ module Groonga
                                    :limit,
                                    :calc_types,
                                    :calc_target,
+                                   :filter,
                                    :label)
       end
 

  Modified: test/command/test-select.rb (+15 -2)
===================================================================
--- test/command/test-select.rb    2017-01-18 09:56:44 +0900 (27d5cae)
+++ test/command/test-select.rb    2017-03-27 12:02:27 +0900 (4329c5f)
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2016  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2011-2017  Kouhei Sutou <kou �� clear-code.com>
 # Copyright (C) 2016  Masafumi Yokoyama <yokoyama �� clear-code.com>
 #
 # This library is free software; you can redistribute it and/or
@@ -45,6 +45,7 @@ class SelectCommandTest < Test::Unit::TestCase
       adjuster                   = "tag * 10"
       drilldown_calc_types       = "MIN, MAX"
       drilldown_calc_target      = "age"
+      drilldown_filter           = "_nsubrecs > 1"
       sort_keys                  = "-_score"
       drilldown_sort_keys        = "-_nsubrecs"
 
@@ -71,6 +72,7 @@ class SelectCommandTest < Test::Unit::TestCase
         adjuster,
         drilldown_calc_types,
         drilldown_calc_target,
+        drilldown_filter,
         sort_keys,
         drilldown_sort_keys,
       ]
@@ -99,6 +101,7 @@ class SelectCommandTest < Test::Unit::TestCase
                      :adjuster                   => adjuster,
                      :drilldown_calc_types       => drilldown_calc_types,
                      :drilldown_calc_target      => drilldown_calc_target,
+                     :drilldown_filter           => drilldown_filter,
                      :sort_keys                  => sort_keys,
                      :drilldown_sort_keys        => drilldown_sort_keys,
                    },
@@ -155,6 +158,14 @@ class SelectCommandTest < Test::Unit::TestCase
     end
   end
 
+  class DrilldownFilterTest < self
+    def test_reader
+      command = select_command(:drilldown_filter => "_nsubrecs > 1")
+      assert_equal("_nsubrecs > 1",
+                   command.drilldown_filter)
+    end
+  end
+
   class DrilldownSortKeysTest < self
     def test_reader
       command = select_command(:drilldown_sort_keys => "-_nsubrecs,_key")
@@ -179,6 +190,7 @@ class SelectCommandTest < Test::Unit::TestCase
         "drilldowns[tag].limit" => "10",
         "drilldowns[tag].calc_types" => "MIN,MAX",
         "drilldowns[tag].calc_target" => "_nsubrecs",
+        "drilldowns[tag].filter" => "_nsubrecs > 1",
 
         "drilldowns[author_tag].keys" => "author,tag",
         "drilldowns[author_tag].sort_keys" => "_value.author",
@@ -205,7 +217,8 @@ class SelectCommandTest < Test::Unit::TestCase
                            :offset => 1,
                            :limit => 10,
                            :calc_types => ["MIN", "MAX"],
-                           :calc_target => "_nsubrecs"),
+                           :calc_target => "_nsubrecs",
+                           :filter => "_nsubrecs > 1"),
       }
       assert_equal(drilldowns,
                    command.labeled_drilldowns)
-------------- next part --------------
HTML����������������������������...
Download 



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