Sha256: 55e867b4acb3c10cef2e4d4bf3eccfae20f9f1364e864c9a66cf4f18cb8e8297

Contents?: true

Size: 1018 Bytes

Versions: 4

Compression:

Stored size: 1018 Bytes

Contents

# frozen_string_literal: true
module SocialNetworking
  module Reports
    # Scenario: a Participant has a Goal.
    class Goal
      # rubocop:disable Metrics/LineLength
      def self.columns
        %w( participant_id created_at due_on is_completed is_deleted description )
      end
      # rubocop:enable Metrics/LineLength

      def self.all
        Participant.select(:id, :study_id).map do |participant|
          ::SocialNetworking::Goal
            .where(participant_id: participant.id).map do |goal|
              {
                participant_id: participant.study_id,
                created_at: goal.created_at.iso8601,
                due_on: goal.due_on ? goal.due_on.iso8601 : "",
                is_completed: goal.is_completed,
                is_deleted: goal.is_deleted,
                description: goal.description
              }
            end
        end.flatten
      end

      def self.to_csv
        ThinkFeelDoEngine::Reports::Reporter.new(self).write_csv
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
social_networking-0.13.2 app/models/social_networking/reports/goal.rb
social_networking-0.13.1 app/models/social_networking/reports/goal.rb
social_networking-0.13.0 app/models/social_networking/reports/goal.rb
social_networking-0.12.0 app/models/social_networking/reports/goal.rb