Sha256: d0a22608c9889de4e4ce5c89cc1a0a57967dc1340a10c856c4e0767b85209b41

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true
module SocialNetworking
  module Reports
    # Scenario: a Participant likes a feed item.
    class Like
      def self.columns
        %w( participant_id occurred_at item_type item_participant_id
            item_content )
      end

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

              {
                participant_id: participant.study_id,
                occurred_at: like.created_at.iso8601,
                item_type: item.class.to_s,
                item_participant_id: item_participant.try(:study_id),
                item_content: like.item_description
              }
            end
        end.flatten.compact
      end

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

Version data entries

5 entries across 5 versions & 1 rubygems

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