decidim-process_groups_content_block 0.16.1 → 0.16.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7d1dc8bfb5244bfcb6d553c752f7e5c3af18b90b35a68af834f862e56aefddf
4
- data.tar.gz: 9156032a3a4c28596ea5a0a9bd763d11e4c101ee58ecffe46257248ce7be49c4
3
+ metadata.gz: 4b661f9f6b0a4db684add997a30a7f30616395eeb19115776e9a83d7d1b4f27a
4
+ data.tar.gz: fcdd78f86c21415c8707e197c643cededb282308921e908ae7e35f2c2f5083df
5
5
  SHA512:
6
- metadata.gz: 1ebe1a7585e5038d27166c6a4225362086728fdbeb9caf2caabacee519c108415151568636b316699ae030a323ed598c80736f48a3e082d66fd3ec0893a3d018
7
- data.tar.gz: d8c072c223ec648ac9b1b19353993a3eeeefe4b51af8e00b2b95fe58ed818c81e7933533261b8c9d1cbccee1efa44441fb1ffa6fcba72be873e7441c9cfa9773
6
+ metadata.gz: fb1d830cf507318b2f8ff4365f2ae64edb97a6964586ee4f843dc9846d6592842e7dac35a130f773fcbc99d701373e09eb7ab90a43865838a5a8451e01911df6
7
+ data.tar.gz: a909a7bbd83c58556763649dd4a394301a88829c9a12467a248f92e5b1f55211a160dbab824117d111fba6351fda0208f52417ebd990a1a55e3924d0af1c1020
@@ -16,18 +16,9 @@ module Decidim
16
16
  end
17
17
 
18
18
  def highlighted_groups
19
- Decidim::ParticipatoryProcesses::OrganizationPrioritizedParticipatoryProcessGroups
19
+ OrganizationActiveParticipatoryProcessGroups
20
20
  .new(current_organization)
21
21
  .query
22
- .joins(:participatory_processes)
23
- .where.not(decidim_participatory_processes: { published_at: nil })
24
- .where(
25
- "decidim_participatory_processes.end_date IS NULL "\
26
- "OR decidim_participatory_processes.end_date > ?",
27
- Time.current
28
- )
29
- .group("decidim_participatory_process_groups.id")
30
- .having("COUNT(decidim_participatory_processes.id) > 0")
31
22
  end
32
23
 
33
24
  def i18n_scope
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ProcessGroupsContentBlock
5
+ # This query class filters participatory process groups given an organization and a filter.
6
+ class OrganizationActiveParticipatoryProcessGroups < Decidim::ParticipatoryProcesses::OrganizationPrioritizedParticipatoryProcessGroups
7
+ def query
8
+ ids = super
9
+ .joins(:participatory_processes)
10
+ .where.not(decidim_participatory_processes: { published_at: nil })
11
+ .where(
12
+ "decidim_participatory_processes.end_date IS NULL "\
13
+ "OR decidim_participatory_processes.end_date > ?",
14
+ Time.current
15
+ )
16
+ .group("decidim_participatory_process_groups.id")
17
+ .having("COUNT(decidim_participatory_processes.id) > 0")
18
+ .pluck(:id)
19
+
20
+ Decidim::ParticipatoryProcessGroup
21
+ .where(id: ids)
22
+ .order(Arel.sql("name ->> '#{current_locale}' ASC"))
23
+ end
24
+
25
+ private
26
+
27
+ def current_locale
28
+ I18n.locale.to_s
29
+ end
30
+ end
31
+ end
32
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Decidim
4
4
  module ProcessGroupsContentBlock
5
- VERSION = "0.16.1"
5
+ VERSION = "0.16.2"
6
6
  DECIDIM_VERSION = "~> 0.16.0"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-process_groups_content_block
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.1
4
+ version: 0.16.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antti Hukkanen
@@ -93,6 +93,7 @@ files:
93
93
  - app/cells/decidim/process_groups_content_block/content_blocks/highlighted_process_groups/_all_groups.erb
94
94
  - app/cells/decidim/process_groups_content_block/content_blocks/highlighted_process_groups/show.erb
95
95
  - app/cells/decidim/process_groups_content_block/content_blocks/highlighted_process_groups_cell.rb
96
+ - app/queries/decidim/process_groups_content_block/organization_active_participatory_process_groups.rb
96
97
  - config/locales/en.yml
97
98
  - config/locales/fi.yml
98
99
  - lib/decidim/process_groups_content_block.rb