mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
fixing bug with last sent attempt
This commit is contained in:
parent
0c2aa09ebc
commit
2f4b28a4b6
3 changed files with 8 additions and 4 deletions
|
|
@ -4,7 +4,7 @@ class AttemptsController < ApplicationController
|
|||
|
||||
def twilio
|
||||
recipient = Recipient.where(phone: twilio_params['From']).first
|
||||
attempt = recipient.attempts.last
|
||||
attempt = recipient.attempts.last_sent.first
|
||||
|
||||
if (twilio_params[:Body].downcase == 'stop')
|
||||
attempt.recipient.update_attributes(opted_out: true)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class Attempt < ApplicationRecord
|
|||
scope :with_answer, -> { where('answer_index is not null or open_response_id is not null')}
|
||||
scope :with_no_answer, -> { where('answer_index is null and open_response_id is null')}
|
||||
scope :not_yet_responded, -> { where(responded_at: nil) }
|
||||
scope :last_sent, -> { order(sent_at: :desc) }
|
||||
|
||||
def messages
|
||||
if student.present?
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ RSpec.describe AttemptsController, type: :controller do
|
|||
schedule: schedule,
|
||||
recipient: recipients.first,
|
||||
recipient_schedule: recipient_schedule,
|
||||
question: questions.first
|
||||
question: questions.first,
|
||||
sent_at: Time.new
|
||||
)
|
||||
}
|
||||
let!(:attempt) {
|
||||
|
|
@ -34,7 +35,8 @@ RSpec.describe AttemptsController, type: :controller do
|
|||
schedule: schedule,
|
||||
recipient: recipients.first,
|
||||
recipient_schedule: recipient_schedule,
|
||||
question: questions.first
|
||||
question: questions.first,
|
||||
sent_at: Time.new
|
||||
)
|
||||
}
|
||||
let!(:attempt2) {
|
||||
|
|
@ -42,7 +44,8 @@ RSpec.describe AttemptsController, type: :controller do
|
|||
schedule: schedule,
|
||||
recipient: recipients.last,
|
||||
recipient_schedule: recipient_schedule2,
|
||||
question: questions.first
|
||||
question: questions.first,
|
||||
sent_at: Time.new
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue