Diff
Modified: branches/discovery/app/controllers/application.rb (2537 => 2538)
--- branches/discovery/app/controllers/application.rb 2010-11-25 16:23:59 UTC (rev 2537)
+++ branches/discovery/app/controllers/application.rb 2010-11-26 15:13:39 UTC (rev 2538)
@@ -617,6 +617,9 @@
raise "Unsupported query _expression_" if counts[:and] > 0 && counts[:or] > 0
+ # haven't implemented 'and' within a particular filter yet
+ raise "Unsupported query _expression_" if counts[:and] > 0
+
if category[:expr].length == 1
category[:expr] = { :terms => [unescape_string(category[:expr].first)] }
else
@@ -648,8 +651,10 @@
if parts.include?(:filter)
bits = []
pivot_options[:filters].each do |filter|
- if find_filter(expr, filter[:query_option])
- bits << filter[:query_option] + "(\"" + find_filter(expr, filter[:query_option])[:expr][:terms].map do |t| t.gsub(/"/, '\"') end.join("\" OR \"") + "\")"
+ if opts[:lock_filter][filter[:query_option]].nil?
+ if find_filter(expr, filter[:query_option])
+ bits << filter[:query_option] + "(\"" + find_filter(expr, filter[:query_option])[:expr][:terms].map do |t| t.gsub(/"/, '\"') end.join("\" OR \"") + "\")"
+ end
end
end
@@ -663,12 +668,6 @@
query.merge!(extra)
- if opts[:lock_filter]
- opts[:lock_filter].keys.each do |filter|
- query.delete(filter)
- end
- end
-
query
end
@@ -849,23 +848,19 @@
# parse the filter _expression_ if provided. convert filter _expression_ to
# the old format. this will need to be replaced eventually
- opts[:filters] = []
+ opts[:filters] ||= []
- if params["filter"]
- opts[:filters] = parse_filter_expression(params["filter"])
+ # filter out top level logic operators for now
- # filter out top level logic operators for now
-
- opts[:filters] = opts[:filters].select do |bit|
- bit.class == Hash
- end
+ opts[:filters] = opts[:filters].select do |bit|
+ bit.class == Hash
end
# apply locked filters
if opts[:lock_filter]
opts[:lock_filter].each do |filter, value|
- params[filter] = value
+ opts[:filters] << { :name => filter, :expr => { :terms => [value] } }
end
end
Modified: branches/discovery/app/controllers/blobs_controller.rb (2537 => 2538)
--- branches/discovery/app/controllers/blobs_controller.rb 2010-11-25 16:23:59 UTC (rev 2537)
+++ branches/discovery/app/controllers/blobs_controller.rb 2010-11-26 15:13:39 UTC (rev 2538)
@@ -57,8 +57,19 @@
respond_to do |format|
format.html {
@pivot_options = pivot_options
+
+ begin
+ expr = parse_filter_expression(params["filter"]) if params["filter"]
+ rescue Exception => ex
+ puts "ex = #{ex.inspect}"
+ flash.now[:error] = "Problem with query _expression_: #{ex}"
+ expr = nil
+ end
+
@pivot = contributions_list(Contribution, params, current_user,
- :lock_filter => { "type" => "Blob" } )
+ :lock_filter => { 'CATEGORY' => 'Blob' },
+ :filters => expr)
+
# index.rhtml
}
end
Modified: branches/discovery/app/controllers/packs_controller.rb (2537 => 2538)
--- branches/discovery/app/controllers/packs_controller.rb 2010-11-25 16:23:59 UTC (rev 2537)
+++ branches/discovery/app/controllers/packs_controller.rb 2010-11-26 15:13:39 UTC (rev 2538)
@@ -30,8 +30,19 @@
respond_to do |format|
format.html {
@pivot_options = pivot_options
+
+ begin
+ expr = parse_filter_expression(params["filter"]) if params["filter"]
+ rescue Exception => ex
+ puts "ex = #{ex.inspect}"
+ flash.now[:error] = "Problem with query _expression_: #{ex}"
+ expr = nil
+ end
+
@pivot = contributions_list(Contribution, params, current_user,
- :lock_filter => { "type" => "Pack" } )
+ :lock_filter => { 'CATEGORY' => 'Pack' },
+ :filters => expr)
+
# index.rhtml
}
end
Modified: branches/discovery/app/controllers/workflows_controller.rb (2537 => 2538)
--- branches/discovery/app/controllers/workflows_controller.rb 2010-11-25 16:23:59 UTC (rev 2537)
+++ branches/discovery/app/controllers/workflows_controller.rb 2010-11-26 15:13:39 UTC (rev 2538)
@@ -167,7 +167,19 @@
respond_to do |format|
format.html do
@pivot_options = pivot_options
- @pivot = contributions_list(Contribution, params, current_user, :lock_filter => { 'type' => 'Workflow' } )
+
+ begin
+ expr = parse_filter_expression(params["filter"]) if params["filter"]
+ rescue Exception => ex
+ puts "ex = #{ex.inspect}"
+ flash.now[:error] = "Problem with query _expression_: #{ex}"
+ expr = nil
+ end
+
+ @pivot = contributions_list(Contribution, params, current_user,
+ :lock_filter => { 'CATEGORY' => 'Workflow' },
+ :filters => expr)
+
end
format.rss do
address@hidden = Workflow.find(:all, :order => "updated_at DESC") # list all (if required)