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)

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 Models::EventPublishable

#publish_event

Instance Attribute Details

#composite_scoreObject (readonly)



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

validates :composite_score, :presence => true

#series_dateObject (readonly)



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

validates :series_date, :presence => true

Class Method Details

.activeActiveRecord::Relation<PostalCodeStatistic>

A relation of PostalCodeStatistics that are active. Active Record Scope

Returns:

See Also:



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

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:



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

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