journalduhacker/app/indices/comment_index.rb
joshua stein 9e8b89be1c cast story.{upvotes,downvotes} to signed on mysql, integer on postgres
old mysql doesn't support 'cast(1 as integer)', but new/mariadb does

postgres doesn't support 'cast(1 as signed)'

should fix #145
2014-10-06 14:07:53 -05:00

15 lines
415 B
Ruby

ThinkingSphinx::Index.define :comment, :with => :active_record do
indexes comment
indexes short_id
indexes user.username, :as => :author
has "(CAST(upvotes as #{Story.votes_cast_type}) - " <<
"CAST(downvotes as #{Story.votes_cast_type}))", :as => :score,
:type => :bigint, :sortable => true
has is_deleted
has created_at
where sanitize_sql(:is_deleted => false, :is_moderated => false)
end