Skip to content

Commit

Permalink
[fix] Include admins in everyone message recipient
Browse files Browse the repository at this point in the history
Fixes #145
  • Loading branch information
sman591 committed May 14, 2019
1 parent a869445 commit 8ac979f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/workers/bulk_message_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class BulkMessageWorker
def perform(message_id)
message = Message.find(message_id)
return unless message.present? && message.status == "queued"

message.update_attribute(:started_at, Time.now)

recipients = self.class.build_recipients(message.recipients)
Expand All @@ -27,8 +28,10 @@ def self.build_recipients(recipient_types)
def self.user_ids(type)
case type
when "all"
User.non_admins.pluck(:id)
# Everyone, including admins that completed a questionnaire
User.non_admins.pluck(:id) + Questionnaire.pluck(:user_id)
when "incomplete"
# Incomplete applications, excluding admins that don't have a questionnaire
User.non_admins.pluck(:id) - Questionnaire.pluck(:user_id)
when "complete"
Questionnaire.pluck(:user_id)
Expand Down Expand Up @@ -74,6 +77,7 @@ def self.user_ids_from_query(type)
result = Blazer::RunStatement.new.perform(Blazer.data_sources[model.data_source], model.statement)
user_id_column = result.columns.index("user_id")
raise "Blazer query is missing required \"user_id\" column" unless user_id_column.present?

result.rows.map { |row| row[user_id_column] }
else
raise "Unknown recipient query type: #{recipient_query.type.inspect} (in message recipient query: #{type.inspect}"
Expand Down

0 comments on commit 8ac979f

Please sign in to comment.