Sha256: 76dc3a364cb0bc32236e8672840b06787f846afdc61a04e0177cfd8b3e05289f

Contents?: true

Size: 878 Bytes

Versions: 15

Compression:

Stored size: 878 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module TermCustomizer
    # This query class filters all assemblies given an organization.
    class OrganizationTranslationSets < Rectify::Query
      def initialize(organization)
        @organization = organization
      end

      def query
        columns = [
          "DISTINCT(decidim_term_customizer_translation_sets.id)",
          "name",
          "name->>'#{current_locale}' AS local_name"
        ]

        q = Decidim::TermCustomizer::TranslationSet.joins(:constraints).where(
          decidim_term_customizer_constraints: {
            decidim_organization_id: @organization.id
          }
        ).select(columns.join(","))
        q.order("local_name")
      end

      def count
        query.count(:id)
      end

      private

      def current_locale
        I18n.locale.to_s
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
decidim-term_customizer-0.23.0 app/queries/decidim/term_customizer/organization_translation_sets.rb
decidim-term_customizer-0.22.0 app/queries/decidim/term_customizer/organization_translation_sets.rb
decidim-term_customizer-0.21.0 app/queries/decidim/term_customizer/organization_translation_sets.rb
decidim-term_customizer-0.20.0 app/queries/decidim/term_customizer/organization_translation_sets.rb
decidim-term_customizer-0.19.1 app/queries/decidim/term_customizer/organization_translation_sets.rb
decidim-term_customizer-0.19.0 app/queries/decidim/term_customizer/organization_translation_sets.rb
decidim-term_customizer-0.18.0 app/queries/decidim/term_customizer/organization_translation_sets.rb
decidim-term_customizer-0.17.1 app/queries/decidim/term_customizer/organization_translation_sets.rb
decidim-term_customizer-0.17.0 app/queries/decidim/term_customizer/organization_translation_sets.rb
decidim-term_customizer-0.16.6 app/queries/decidim/term_customizer/organization_translation_sets.rb
decidim-term_customizer-0.16.5 app/queries/decidim/term_customizer/organization_translation_sets.rb
decidim-term_customizer-0.16.3 app/queries/decidim/term_customizer/organization_translation_sets.rb
decidim-term_customizer-0.16.2 app/queries/decidim/term_customizer/organization_translation_sets.rb
decidim-term_customizer-0.16.1 app/queries/decidim/term_customizer/organization_translation_sets.rb
decidim-term_customizer-0.16.0 app/queries/decidim/term_customizer/organization_translation_sets.rb