Sha256: 88b6dea1d979310a22055b49f2773cd9ba12032b764839ddd14c965d261cd4fe

Contents?: true

Size: 625 Bytes

Versions: 9

Compression:

Stored size: 625 Bytes

Contents

require 'thredded/topic_sql_builder'
require 'thredded/post_sql_builder'

module Thredded
  class SearchSqlBuilder
    def initialize(query, messageboard)
      @topic_builder = TopicSqlBuilder.new(query, messageboard)
      @post_builder = PostSqlBuilder.new(query, messageboard)
      @order_by = 'ORDER BY updated_at DESC'
    end

    def build
      [
        'SELECT * FROM thredded_topics WHERE id IN (', @post_builder.sql,
        'UNION', @topic_builder.sql,
        ')', @order_by,
        'LIMIT 50'
      ].join(' ')
    end

    def binds
      @post_builder.binds.concat(@topic_builder.binds)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
thredded-0.0.12 lib/thredded/search_sql_builder.rb
thredded-0.0.10 lib/thredded/search_sql_builder.rb
thredded-0.0.9 lib/thredded/search_sql_builder.rb
thredded-0.0.8 lib/thredded/search_sql_builder.rb
thredded-0.0.7 lib/thredded/search_sql_builder.rb
thredded-0.0.6 lib/thredded/search_sql_builder.rb
thredded-0.0.5 lib/thredded/search_sql_builder.rb
thredded-0.0.4 lib/thredded/search_sql_builder.rb
thredded-0.0.3 lib/thredded/search_sql_builder.rb