Skip to content

Commit

Permalink
Taking kudos out of work index
Browse files Browse the repository at this point in the history
  • Loading branch information
elzj committed Jun 30, 2012
1 parent 743b89c commit 9a4cab9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
3 changes: 0 additions & 3 deletions app/models/work.rb
Expand Up @@ -1096,9 +1096,6 @@ def <=>(another_work)
has bookmarks.rec, :as => 'recced'
has bookmarks.pseud_id, :as => 'bookmarker'

has kudos(:id), :as => :kudos_id
has "COUNT(DISTINCT kudos.id)", :as => :kudo_count, :type => :integer

# properties
# set_property :delta => :delayed
set_property :field_weights => {
Expand Down
2 changes: 0 additions & 2 deletions app/views/works/search.html.erb
Expand Up @@ -17,7 +17,6 @@
<%= hidden_field_tag "query[author]", @query[:author] %>
<%= hidden_field_tag "query[words]", @query[:words] %>
<%= hidden_field_tag "query[hits]", @query[:hits] %>
<%= hidden_field_tag "query[kudos]", @query[:kudos] %>
<%= hidden_field_tag "query[date]", @query[:date] %>
<%= hidden_field_tag "query[language]", @query[:language] %>
<%= hidden_field_tag "query[bookmarked]", @query[:bookmarked] %>
Expand Down Expand Up @@ -48,7 +47,6 @@
<% unless @query[:author].blank? %><%= ts('Author') %>: <%= @query[:author] %> <% end %>
<% unless @query[:words].blank? %><%= ts('Words') %>: <%= @query[:words] %> <% end %>
<% unless @query[:hits].blank? %><%= ts('Hits') %>: <%= @query[:hits] %> <% end %>
<% unless @query[:kudos].blank? %><%= ts('Kudos') %>: <%= @query[:kudos] %> <% end %>
<% unless @query[:date].blank? %><%= ts('Date') %>: <%= @query[:date] %> <% end %>
<% unless @query[:language].blank? %><%= ts('Language') %>: <%= @query[:language] %> <% end %>
<% unless @query[:bookmarked].blank? %><%= ts('Bookmarked') %><% end %>
Expand Down
6 changes: 3 additions & 3 deletions lib/query.rb
Expand Up @@ -6,7 +6,7 @@ module Query
BOOKMARK_FIELDS = %w{tag indirect notes bookmarker}
PEOPLE_FIELDS = %w{id name icon_alt_text description}
ALL_FIELDS = (WORK_FIELDS + BOOKMARK_FIELDS + PEOPLE_FIELDS).uniq
ALL_INDEXES = ALL_FIELDS + %w{words hits kudos date rec canonical recced bookmarked}
ALL_INDEXES = ALL_FIELDS + %w{words hits date rec canonical recced bookmarked}

# this does the actual search on the class given a standardized query hash
def Query.search_with_sphinx(klass, query, page)
Expand Down Expand Up @@ -63,7 +63,7 @@ def Query.standardize(query)
query.delete_if { |k, v| v.blank? }
# in rails 3, a query with < or > will get encoded, unencode them again
# also, remove punctuation such as , and . (10.000 == 10,000 == 10000)
for string in %w{word hit kudo bookmark date} do
for string in %w{word hit bookmark date} do
sym = string.pluralize.to_sym unless string == "date"
sym = string.to_sym if string == "date"
query[sym] = query[sym].gsub("&gt;", ">").gsub("&lt;", "<").gsub(/[,.]/, "") if query[sym]
Expand All @@ -90,7 +90,7 @@ def Query.split_query(query={})
text = (text + " @" + string + " " + query[string.to_sym]) unless query[string.to_sym].blank?
end
text = (text + " @type " + query[:type]) unless query[:type].blank?
for string in %w{word hit kudo bookmark} do
for string in %w{word hit bookmark} do
sym = string.pluralize.to_sym
unless query[sym].blank?
match = query[sym].match(/^([<>]*)\s*([\d,. -]+)\s*$/)
Expand Down

0 comments on commit 9a4cab9

Please sign in to comment.