Sha256: da3cdc75967e1234da6f5cc97877d294ff7628291026bad974b43db1601d3bae
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true require_dependency "renalware/events" module Renalware module Events class SummaryPart < Renalware::SummaryPart def recent_events @recent_events ||= begin Events::Event.includes([:created_by, :event_type]) .for_patient(patient) .limit(Renalware.config.clinical_summary_max_events_to_display) .ordered end end def recent_events_count title_friendly_collection_count( actual: recent_events.size, total: patient.summary.events_count ) end # AR::Relation#cache_key here will issue: # SELECT COUNT(*) AS "size", MAX("events"."updated_at") AS timestamp # FROM "events" WHERE "events"."patient_id" = 1 # and use size and timestamp in the cache key. # We purposefully don't use the recent_events relation here as it has includes and a limit # and apart from being slower, using LIMIT in cache_key sql has been known to produce # inconsistent results. def cache_key Events::Event.for_patient(patient).cache_key end def to_partial_path "renalware/events/events/summary_part" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
renalware-core-2.0.0.pre.rc13 | app/presenters/renalware/events/summary_part.rb |