about summary refs log tree commit diff
path: root/app/helpers/application_helper.rb
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-03-02 18:02:48 +0100
committerClaire <claire.github-309c@sitedethib.com>2022-03-02 18:02:48 +0100
commit425a6c90c44a620e5015cd659cf5d8e3bf68ee07 (patch)
tree1bb889bca498b07dd4f3a56a5690ea9c2f602382 /app/helpers/application_helper.rb
parent0b8fe020b599341d78cc03431eb156485c70ebea (diff)
parent462a6f7d721fa0717c5627fd0f0d73ee9ec5a675 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'app/helpers/application_helper.rb')
-rw-r--r--app/helpers/application_helper.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 8b41033a5..818253e86 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -225,4 +225,19 @@ module ApplicationHelper
     content_tag(:script, json_escape(json).html_safe, id: 'initial-state', type: 'application/json')
     # rubocop:enable Rails/OutputSafety
   end
+
+  def grouped_scopes(scopes)
+    scope_parser      = ScopeParser.new
+    scope_transformer = ScopeTransformer.new
+
+    scopes.each_with_object({}) do |str, h|
+      scope = scope_transformer.apply(scope_parser.parse(str))
+
+      if h[scope.key]
+        h[scope.key].merge!(scope)
+      else
+        h[scope.key] = scope
+      end
+    end.values
+  end
 end