Class: Renalware::Pathology::ChartComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Renalware::Pathology::ChartComponent
- Defined in:
- app/components/renalware/pathology/chart_component.rb
Instance Method Summary collapse
-
#cache_key ⇒ Object
TODO: cache key should expire when a new observation arrives of this type.
- #chart_data ⇒ Object
- #dom_id ⇒ Object
- #options ⇒ Object
-
#render? ⇒ Boolean
Because we cache the component html inside the view sidecar, we want to avoid implementing this method properly - ie checking if there anything to render - as that would involve querying the database, thus negating the befit of any caching.
Methods inherited from ApplicationComponent
Instance Method Details
#cache_key ⇒ Object
TODO: cache key should expire when a new observation arrives of this type
19 20 21 |
# File 'app/components/renalware/pathology/chart_component.rb', line 19 def cache_key "#{patient.cache_key}/chart/#{observation_description.id}" end |
#chart_data ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'app/components/renalware/pathology/chart_component.rb', line 8 def chart_data @chart_data ||= begin Pathology.cast_patient(patient) .observations .where(description_id: observation_description.id) .order(:observed_at) .pluck([:observed_at, :result]) end end |
#dom_id ⇒ Object
35 36 37 |
# File 'app/components/renalware/pathology/chart_component.rb', line 35 def dom_id @dom_id ||= ActionView::RecordIdentifier.dom_id(observation_description) end |
#options ⇒ Object
31 32 33 |
# File 'app/components/renalware/pathology/chart_component.rb', line 31 def {} end |
#render? ⇒ Boolean
Because we cache the component html inside the view sidecar, we want to avoid implementing this method properly - ie checking if there anything to render - as that would involve querying the database, thus negating the befit of any caching.
27 28 29 |
# File 'app/components/renalware/pathology/chart_component.rb', line 27 def render? true end |