Sha256: 086bd15c8c3d03942fd9b01db020cdefa5d7c8959576c2c7cd3b5a366052acea

Contents?: true

Size: 911 Bytes

Versions: 4

Compression:

Stored size: 911 Bytes

Contents

# frozen_string_literal: true
module SocialNetworking
  module Reports
    # Scenario: a Participant comments on a feed item.
    class Comment
      def self.columns
        %w( participant_id occurred_at item_type text )
      end

      def self.all
        Participant.select(:id, :study_id).map do |participant|
          ::SocialNetworking::Comment
            .where(participant_id: participant.id).map do |comment|
              item = (comment.item.try(:item) || comment.item)
              next if item.nil?

              {
                participant_id: participant.study_id,
                occurred_at: comment.created_at.iso8601,
                item_type: item.class.to_s,
                text: comment.text
              }
            end
        end.flatten.compact
      end

      def self.to_csv
        ThinkFeelDoEngine::Reports::Reporter.new(self).write_csv
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
social_networking-0.13.2 app/models/social_networking/reports/comment.rb
social_networking-0.13.1 app/models/social_networking/reports/comment.rb
social_networking-0.13.0 app/models/social_networking/reports/comment.rb
social_networking-0.12.0 app/models/social_networking/reports/comment.rb