Sha256: bc64a944341e23bf5c179083b5ef4e87a759c49eb790eab32eca6d5b54e9f23d

Contents?: true

Size: 740 Bytes

Versions: 24

Compression:

Stored size: 740 Bytes

Contents

module Concerns
  module FestivitySqlBuilder

    extend ActiveSupport::Concern

    included do

      def self.advance_by(filter_type)
        advance_by_hash = {minutes: 59}
        advance_by_hash[:hours] = 23 if filter_type == "date"
        advance_by_hash
      end

      def self.parse_categories(category_ids)
        grouped_ids = FestivityCategory.find(category_ids).group_by {|category| category.festivity_category_type}
        category_clauses = grouped_ids.map do |categories|
          "page_id IN (SELECT page_id FROM festivity_page_categories WHERE festivity_category_id IN (#{categories[1].map {|category| category.id}.join(",")}))"
        end
        "(#{category_clauses.join(" AND ")})"

      end

    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
trusty-festivity-extension-2.5.3 app/controllers/concerns/festivity_sql_builder.rb
trusty-festivity-extension-2.5.2 app/controllers/concerns/festivity_sql_builder.rb
trusty-festivity-extension-2.5.1 app/controllers/concerns/festivity_sql_builder.rb
trusty-festivity-extension-2.5.0 app/controllers/concerns/festivity_sql_builder.rb