Commit 2a05ea07 by ivan Lan

Add Other::WeatherIndex

parent a0f74c90
class CreateWeatherIndex < ActiveRecord::Migration[5.0]
def up
create_table :weather_index do |t|
t.datetime :publishtime
t.string :type
t.text :list
t.timestamps
end
add_index :weather_index, :publishtime
end
def down
drop_table :weather_index
end
end
......@@ -2,7 +2,7 @@ module WeatherModel
module SourceSchema
def self.sorts
[:Forecast, :AutoStation, :Aqi, :Warning]
[:Forecast, :AutoStation, :Aqi, :Warning, :Other]
end
Dir[File.join(File.dirname(__FILE__), 'source_schemas/*.rb')].each { |file|
......
module WeatherModel
module SourceSchema
WeatherIndex = {
sort: 'Other',
table_name: :weather_index,
schema: {
publishtime: :datetime,
type: :string,
list: :text
},
options: {
index: [:publishtime],
expire: 3 * 24 * 60 * 60,
json_column: :list
},
factory_name: :weather_index,
factory: {
publishtime: Time.parse('2017-05-16 16:00'),
warning_type: "雷电",
list: [
{:detail=>"日照强度强,外出需加强防护。", :id=>"1", :level=>"3级", :mean=>"加强防护", :name=>"日照指数", :shortcues=>"强", :time=>"2017-06-02"},
{:detail=>"气温适宜,人体感觉略偏暖,较为舒适。", :id=>"2", :level=>"1级", :mean=>"气温适宜,人体感觉略偏暖,较为舒适", :name=>"体感指数(上午)", :shortcues=>"较舒适", :time=>"2017-06-02"}
]
}
}
end
end
......@@ -113,7 +113,8 @@ RSpec.describe WeatherModel do
WeatherModel::AutoStation::AutoStationTenMins,
WeatherModel::Aqi::AqiForecast,
WeatherModel::Aqi::AqiLive,
WeatherModel::Warning::WarningDistrict
WeatherModel::Warning::WarningDistrict,
WeatherModel::Other::WeatherIndex
].each { |source|
# create factory
source.all; source.const_get('Ohm').all.first;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment