Class: DashOverlord::Models::V1::ChartConfig
- Defined in:
- lib/dash_overlord/models/v1/chart_config.rb
Constant Summary collapse
- ALLOWED_FONT_STYLES =
%w(normal italic bold).freeze
- ALLOWED_FUNCTIONS =
%w(percentage count).freeze
Class Method Summary collapse
Instance Method Summary collapse
- #allowed_sources ⇒ Object
- #answers ⇒ Object
- #cached_answer_values_outdated? ⇒ Boolean
- #last_answer ⇒ Object
Class Method Details
.allowed_sources(project_id) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/dash_overlord/models/v1/chart_config.rb', line 10 def self.allowed_sources(project_id) return [] unless project_id # questions = project.questions questions = [OpenStruct.new(id: 1, question: 'How old are you')] questions.map do |question| Entities::V1::ChartSource.new \ id: question.id.to_s, value: question.question end end |
Instance Method Details
#allowed_sources ⇒ Object
23 24 25 |
# File 'lib/dash_overlord/models/v1/chart_config.rb', line 23 def allowed_sources self.class.allowed_sources(project_id) end |
#answers ⇒ Object
27 28 29 30 31 |
# File 'lib/dash_overlord/models/v1/chart_config.rb', line 27 def answers # @answers ||= # ::Answer.where project_id: project_id, question_id: source.to_i [] end |
#cached_answer_values_outdated? ⇒ Boolean
37 38 39 40 41 42 43 |
# File 'lib/dash_overlord/models/v1/chart_config.rb', line 37 def cached_answer_values_outdated? return cached_answer_updated_at.present? unless last_answer return true unless cached_answer_updated_at last_answer.updated_at > cached_answer_updated_at end |
#last_answer ⇒ Object
33 34 35 |
# File 'lib/dash_overlord/models/v1/chart_config.rb', line 33 def last_answer @last_answer ||= answers.last end |