Sha256: ecfcea5aac4cecfc2b32086bee213bf6ac337b012cc0e48f711ef1f59f315cc7

Contents?: true

Size: 782 Bytes

Versions: 11

Compression:

Stored size: 782 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Comments
    module Export
      # Public: Given a resource class and a component, returns the comments for that
      # resource in that component.
      #
      # resource_class - The resource's Class
      # component        - The component where the resource is scoped to.
      #
      # Returns an Arel::Relation with all the comments for that component and resource.
      def comments_for_resource(resource_class, component)
        Comment
          .where(decidim_root_commentable_id: resource_class.where(component: component))
          .not_deleted
          .not_hidden
          .where(decidim_root_commentable_type: resource_class.to_s)
      end

      module_function :comments_for_resource
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
decidim-comments-0.27.9 lib/decidim/comments/export.rb
decidim-comments-0.27.8 lib/decidim/comments/export.rb
decidim-comments-0.27.7 lib/decidim/comments/export.rb
decidim-comments-0.27.6 lib/decidim/comments/export.rb
decidim-comments-0.26.10 lib/decidim/comments/export.rb
decidim-comments-0.26.9 lib/decidim/comments/export.rb
decidim-comments-0.27.5 lib/decidim/comments/export.rb
decidim-comments-0.26.8 lib/decidim/comments/export.rb
decidim-comments-0.27.4 lib/decidim/comments/export.rb
decidim-comments-0.27.3 lib/decidim/comments/export.rb
decidim-comments-0.26.7 lib/decidim/comments/export.rb