Class: Decidim::TermCustomizer::OrganizationTranslationSets

Inherits:
Rectify::Query
  • Object
show all
Defined in:
app/queries/decidim/term_customizer/organization_translation_sets.rb

Overview

This query class filters all assemblies given an organization.

Instance Method Summary collapse

Constructor Details

#initialize(organization) ⇒ OrganizationTranslationSets

Returns a new instance of OrganizationTranslationSets.



7
8
9
# File 'app/queries/decidim/term_customizer/organization_translation_sets.rb', line 7

def initialize(organization)
  @organization = organization
end

Instance Method Details

#countObject



26
27
28
# File 'app/queries/decidim/term_customizer/organization_translation_sets.rb', line 26

def count
  query.count(:id)
end

#queryObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/queries/decidim/term_customizer/organization_translation_sets.rb', line 11

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