Sha256: 15e32ec2fa6356d01c6303510883b1d2e1057f7cdc18f8f43cb79a3ff2e06025

Contents?: true

Size: 721 Bytes

Versions: 17

Compression:

Stored size: 721 Bytes

Contents

require_dependency "renalware/clinics"

module Renalware
  module Events
    class EventQuery
      attr_reader :query, :patient

      def initialize(patient:, query: {})
        @query = query
        @patient = patient
        @query[:s] = "created_at DESC" if @query[:s].blank?
      end

      def call
        search.result.for_patient(patient)
                     .includes(:event_type)
                     .eager_load(:event_type)
                     .includes(:created_by)
                     .eager_load(:created_by)
                     .page(query[:page]).per(query[:per_page])
                     .ordered
      end

      def search
        @search ||= Event.ransack(query)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.rc10 app/models/renalware/events/event_query.rb
renalware-core-2.0.0.pre.rc9 app/models/renalware/events/event_query.rb
renalware-core-2.0.0.pre.rc8 app/models/renalware/events/event_query.rb
renalware-core-2.0.0.pre.rc7 app/models/renalware/events/event_query.rb
renalware-core-2.0.0.pre.rc6 app/models/renalware/events/event_query.rb
renalware-core-2.0.0.pre.rc5 app/models/renalware/events/event_query.rb
renalware-core-2.0.0.pre.rc4 app/models/renalware/events/event_query.rb
renalware-core-2.0.0.pre.rc3 app/models/renalware/events/event_query.rb
renalware-core-2.0.0.pre.rc1 app/models/renalware/events/event_query.rb
renalware-core-2.0.0.pre.beta12 app/models/renalware/events/event_query.rb
renalware-core-2.0.0.pre.beta11 app/models/renalware/events/event_query.rb
renalware-core-2.0.0.pre.beta10 app/models/renalware/events/event_query.rb
renalware-core-2.0.0.pre.beta9 app/models/renalware/events/event_query.rb
renalware-core-2.0.0.pre.beta8 app/models/renalware/events/event_query.rb
renalware-core-2.0.0.pre.beta7 app/models/renalware/events/event_query.rb
renalware-core-2.0.0.pre.beta6 app/models/renalware/events/event_query.rb
renalware-core-2.0.0.pre.beta5 app/models/renalware/events/event_query.rb