Class: Diaspora::Exporter::OthersRelayables

Inherits:
Object
  • Object
show all
Defined in:
lib/diaspora/exporter/others_relayables.rb

Overview

This class implements methods that allow to query relayables (comments, likes, participations, poll_participations) of other people for posts of the given person.

Instance Method Summary collapse

Constructor Details

#initialize(person_id) ⇒ OthersRelayables

Returns a new instance of OthersRelayables.

Parameters:

  • person_id (Integer)

    Database id of a person for whom we want to request relayalbes


9
10
11
# File 'lib/diaspora/exporter/others_relayables.rb', line 9

def initialize(person_id)
  @person_id = person_id
end

Instance Method Details

#commentsComment::ActiveRecord_Relation

Comments of other people to the person's post

Returns:

  • (Comment::ActiveRecord_Relation)

15
16
17
18
19
20
# File 'lib/diaspora/exporter/others_relayables.rb', line 15

def comments
  Comment
    .where.not(author_id: person_id)
    .joins("INNER JOIN posts ON (commentable_type = 'Post' AND posts.id = commentable_id)")
    .where("posts.author_id = ?", person_id)
end

#likesLike::ActiveRecord_Relation

Likes of other people to the person's post

Returns:

  • (Like::ActiveRecord_Relation)

24
25
26
27
28
29
# File 'lib/diaspora/exporter/others_relayables.rb', line 24

def likes
  Like
    .where.not(author_id: person_id)
    .joins("INNER JOIN posts ON (target_type = 'Post' AND posts.id = target_id)")
    .where("posts.author_id = ?", person_id)
end

#poll_participationsPollParticipation::ActiveRecord_Relation

Poll participations of other people to the person's polls

Returns:

  • (PollParticipation::ActiveRecord_Relation)

33
34
35
36
37
# File 'lib/diaspora/exporter/others_relayables.rb', line 33

def poll_participations
  PollParticipation
    .where.not(author_id: person_id).joins(:status_message)
    .where("posts.author_id = ?", person_id)
end