Class: Lita::Standups::Models::StandupSession

Inherits:
Base
  • Object
show all
Includes:
Ohm::Callbacks, Ohm::DataTypes, Ohm::Timestamps
Defined in:
lib/lita/standups/models/standup_session.rb

Instance Method Summary collapse

Methods inherited from Base

redis

Instance Method Details

#before_createObject



27
28
29
30
# File 'lib/lita/standups/models/standup_session.rb', line 27

def before_create
  self.status = 'pending'
  self.results_sent = "0"
end

#descriptionObject



58
59
60
61
62
63
64
65
# File 'lib/lita/standups/models/standup_session.rb', line 58

def description
  messages = ["ID: #{id}"]
  messages << "Standup: #{standup.name}"
  messages << "Date: #{created_at.strftime('%c')}"
  messages << "Total recipients: #{counts['total']}"
  messages << "Total finished: #{counts['finished']}"
  messages.join("\n")
end

#report_messageObject



50
51
52
# File 'lib/lita/standups/models/standup_session.rb', line 50

def report_message
  standup_responses.map(&:report_message).join("\n")
end

#summaryObject



54
55
56
# File 'lib/lita/standups/models/standup_session.rb', line 54

def summary
  "ID: #{id} - standup #{standup.name} ran on #{created_at.strftime('%c')}"
end

#update_statusObject



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/lita/standups/models/standup_session.rb', line 38

def update_status
  counts = { 'total' => 0, 'finished' => 0 }
  standup_responses.each do |r|
    counts[r.status] = counts[r.status].to_i + 1
    counts['total'] = counts['total'] + 1
    counts['finished'] = counts['finished'] + 1 if r.finished?
  end
  self.counts = counts
  completed! if counts['total'] == counts['finished']
  save
end