Sha256: 1066be5080a097e98dd44d7f03fb39fef392e6a208ad3be864df7c016b6eadad

Contents?: true

Size: 959 Bytes

Versions: 11

Compression:

Stored size: 959 Bytes

Contents

module ThinkFeelDoEngine
  module Reports
    # Scenario: a Participant completes a Task on the assigned day.
    class TaskCompletion
      def self.columns
        %w( participant_id title completed_on )
      end

      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
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
think_feel_do_engine-3.19.9 app/models/think_feel_do_engine/reports/task_completion.rb
think_feel_do_engine-3.19.8 app/models/think_feel_do_engine/reports/task_completion.rb
think_feel_do_engine-3.19.7 app/models/think_feel_do_engine/reports/task_completion.rb
think_feel_do_engine-3.19.6 app/models/think_feel_do_engine/reports/task_completion.rb
think_feel_do_engine-3.19.5 app/models/think_feel_do_engine/reports/task_completion.rb
think_feel_do_engine-3.19.4 app/models/think_feel_do_engine/reports/task_completion.rb
think_feel_do_engine-3.19.3 app/models/think_feel_do_engine/reports/task_completion.rb
think_feel_do_engine-3.19.2 app/models/think_feel_do_engine/reports/task_completion.rb
think_feel_do_engine-3.19.1 app/models/think_feel_do_engine/reports/task_completion.rb
think_feel_do_engine-3.19.0 app/models/think_feel_do_engine/reports/task_completion.rb
think_feel_do_engine-3.18.0 app/models/think_feel_do_engine/reports/task_completion.rb