Class: PostalCodeStatistic

Inherits:
ApplicationRecord show all
Defined in:
app/models/postal_code_statistic.rb

Overview

== Schema Information

Table name: postal_code_statistics
Database name: primary

id :integer not null, primary key
code :string(10)
cold_climate_index :integer
composite_score :integer
demand_index_score :integer
msa :string(255)
msa_fip :integer
num_key_hhs :integer
rri_forecast :integer
series_date :datetime
string :string(10)
zip_code_demand_score :integer
zip_code_relative_activity_score :integer

Indexes

index_postal_code_statistics_on_code_and_series_date (code,series_date) UNIQUE
index_postal_code_statistics_on_composite_score (composite_score)

Constant Summary

Constants included from Schedulable

Schedulable::SIMPLE_FORM_OPTIONS

Instance Attribute Summary collapse

Belongs to collapse

Class Method Summary collapse

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#composite_scoreObject (readonly)



29
# File 'app/models/postal_code_statistic.rb', line 29

validates :composite_score, presence: true

#series_dateObject (readonly)



30
# File 'app/models/postal_code_statistic.rb', line 30

validates :series_date, presence: true

Class Method Details

.activeActiveRecord::Relation<PostalCodeStatistic>

A relation of PostalCodeStatistics that are active. Active Record Scope

Returns:

See Also:



32
# File 'app/models/postal_code_statistic.rb', line 32

scope :active, -> { where("series_date = (select max(series_date) from postal_code_statistics r2 where r2.code = postal_code_statistics.code)") }

Instance Method Details

#postal_codePostalCode

Returns:

See Also:

Validations:



27
# File 'app/models/postal_code_statistic.rb', line 27

belongs_to :postal_code, primary_key: :code, foreign_key: :code, optional: true