Class: ThinkFeelDoEngine::Reports::TaskCompletion

Inherits:
Object
  • Object
show all
Defined in:
app/models/think_feel_do_engine/reports/task_completion.rb

Overview

Scenario: a Participant completes a Task on the assigned day.

Class Method Summary collapse

Class Method Details

.allObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/models/think_feel_do_engine/reports/task_completion.rb', line 10

def self.all
  Participant.not_moderator.select(:id, :study_id)
             .includes(:memberships).map do |participant|
    next unless participant.active_membership

    TaskStatus.where(membership_id: participant.active_membership.id)
              .map do |task_status|
      next unless task_status.completed_at.try(:to_date) ==
                  participant.active_membership.start_date +
                  task_status.start_day - 1

      {
        participant_id: participant.study_id,
        title: task_status.task.title,
        completed_on: task_status.completed_at.to_date.iso8601
      }
    end
  end.flatten.compact
end

.columnsObject



6
7
8
# File 'app/models/think_feel_do_engine/reports/task_completion.rb', line 6

def self.columns
  %w( participant_id title completed_on )
end