Class: Doodle::Protocol::FinderService

Inherits:
Object
  • Object
show all
Defined in:
app/services/doodle/protocol/finder_service.rb

Instance Method Summary collapse

Instance Method Details

#find_by_conversation(id) ⇒ Object



22
23
24
# File 'app/services/doodle/protocol/finder_service.rb', line 22

def find_by_conversation(id)
  Protocol.find_by_conversation_id(id)
end

#next(channel) ⇒ Object



3
4
5
6
7
8
9
# File 'app/services/doodle/protocol/finder_service.rb', line 3

def next(channel)
  protocol = Protocol.in_channel_with_status(user_channels_ids(user), Protocol::STATUSES[:waiting]).first
  return nil if protocol.blank?
  protocol.progress!
  protocol

end

#next_for_user(user) ⇒ Object



11
12
13
14
15
16
# File 'app/services/doodle/protocol/finder_service.rb', line 11

def next_for_user(user)
  protocol = Protocol.in_channels_with_status(user_channels_ids(user), Protocol::STATUSES[:waiting]).first
  return nil if protocol.blank?
  protocol.progress!
  protocol
end

#waiting_on_user_channels(user) ⇒ Object



18
19
20
# File 'app/services/doodle/protocol/finder_service.rb', line 18

def waiting_on_user_channels(user)
  Protocol.in_channels_with_status(user_channels_ids(user), Protocol::STATUSES[:waiting])
end