Class: SocialNetworking::Reports::Like

Inherits:
Object
  • Object
show all
Defined in:
app/models/social_networking/reports/like.rb

Overview

Scenario: a Participant likes a feed item.

Class Method Summary collapse

Class Method Details

.allObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/social_networking/reports/like.rb', line 11

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

.columnsObject



6
7
8
9
# File 'app/models/social_networking/reports/like.rb', line 6

def self.columns
  %w( participant_id occurred_at item_type item_participant_id
      item_content )
end

.to_csvObject



31
32
33
# File 'app/models/social_networking/reports/like.rb', line 31

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