-
-
Save gudata/1510539 to your computer and use it in GitHub Desktop.
code logic review
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= simple_form_for @search, :as => :search_manufacturer, :url => search_index_url(:search => @search.to_hash), :html => {:novalidate => true, :method => :get} do |search_form|%> | |
<% SimpleForm.wrapper_tag = nil %> | |
<!-- Center everything --> | |
<div class="center-content" itemscope itemtype ="http://schema.org/Product"> | |
<article> | |
<!-- 1 column box with tabs --> | |
<div class="tabs"> | |
<nav> | |
<%= render_filter search_form, @search.filter("boat_manufacturer") %> | |
</nav> | |
<div itemproperties="description"> | |
<div class="manufacturer_list"> | |
<%= @result_set.search.facet_set.to_json%> | |
<%= search_form.input 'list', :input_html => { :value => @result_set.search.facet_set.to_json, :id => "hidden_manufacturer_list", :type => 'hidden' }, :label => false %> | |
</div> | |
</div> | |
<div> | |
</div> | |
<div> | |
</div> | |
<div> | |
</div> | |
<div> | |
</div> | |
<div> | |
</div> | |
<div> | |
</div> | |
<div> | |
</div> | |
<footer> | |
<div class="clear"></div> | |
<div class="view-all"> | |
<a href="#">view all »</a> | |
</div> | |
</footer> | |
</div> | |
</article> | |
</div> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To change this template, choose Tools | Templates | |
# and open the template in the editor. | |
class Vanilla::Facets::Manufacturer < Vanilla::Facets::Facet | |
# def initialize | |
# end | |
def load_from_response response | |
@rows = [] | |
data = response[:facet_counts][:facet_fields][field_name] | |
Rails.logger.debug "Wooooooooooooooooooooooowwwwwwwwwwwwwwwwwwwwwwwwww" | |
Rails.logger.debug data.inspect | |
data.each_slice(2).each_with_index do |(label, count), order| | |
row = Vanilla::Facets::Row.new(self) | |
row.order = order | |
# each facet could override this method | |
bucket = Vanilla::Facets::Bucket.new(row, { | |
:label => (label.blank? ? '__blank__' : label), | |
:count => count, | |
:query => label, | |
:label_callback => method(:normal_formatter) | |
} | |
) | |
if !add_bucket_to_selected_buckets(bucket) | |
row << bucket | |
@rows << row | |
end | |
end | |
#Rails.logger.debug "row.inspect #{@rows.inspect}" | |
do_sort | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_data_against_item_type search, item_type, options={:format => :hash} | |
@search = search | |
#Rails.logger.debug(@search.inspect) | |
@query_hash.merge! facets_query(search) | |
#@query_hash.merge! 'facet.field' => :manufacturer, 'facet.sort' => 'count', 'facet.limit' => 5, :rows => 0 | |
@query_hash.merge! {'facet.limit' => 5, | |
:rows => 0, | |
:item_type => item_type} | |
# results_array = [] | |
item = Api::Item.new | |
results_hash = {} | |
results_hash = item.normal :query => @query_hash, :format => options[:format] | |
results_hash | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SearchController < ApplicationController | |
include Vanilla::SearchController | |
def search_form | |
query_builder = Vanilla::Factory::query_builder | |
Rails.logger.debug @search.inspect | |
item_type="motorboat" | |
results_hash=query_builder.get_data_against_item_type @search, item_type | |
Rails.logger.debug("==== Make a ResultSet") | |
@result_set = ResultSet.new(@search, results_hash) | |
Rails.logger.debug "Results_Set=#{@result_set.search.facet_set.inspect}" | |
# Rails.logger.debug(@result_set.inspect) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment