Class: PostalCodeStatistic
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- PostalCodeStatistic
- 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
- #composite_score ⇒ Object readonly
- #series_date ⇒ Object readonly
Belongs to collapse
Class Method Summary collapse
-
.active ⇒ ActiveRecord::Relation<PostalCodeStatistic>
A relation of PostalCodeStatistics that are active.
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Schedulable
Methods included from Models::AfterCommittable
Methods included from Models::EventPublishable
Instance Attribute Details
#composite_score ⇒ Object (readonly)
29 |
# File 'app/models/postal_code_statistic.rb', line 29 validates :composite_score, presence: true |
#series_date ⇒ Object (readonly)
30 |
# File 'app/models/postal_code_statistic.rb', line 30 validates :series_date, presence: true |
Class Method Details
.active ⇒ ActiveRecord::Relation<PostalCodeStatistic>
A relation of PostalCodeStatistics that are active. Active Record Scope
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_code ⇒ PostalCode
Validations:
27 |
# File 'app/models/postal_code_statistic.rb', line 27 belongs_to :postal_code, primary_key: :code, foreign_key: :code, optional: true |