Commit 0afaa0cc by ivan Lan

Add warning_district

parent 0b4ba35b
class CreateWarningDistrict < ActiveRecord::Migration[5.0]
def up
create_table :warning_district do |t|
t.datetime :publishtime
t.string :warning_type
t.string :level
t.string :content
t.string :unit
t.timestamps
end
add_index :warning_district, :publishtime
end
def down
drop_table :warning_district
end
end
......@@ -2,7 +2,7 @@ module WeatherModel
module SourceSchema
def self.sorts
[:Forecast, :AutoStation, :Aqi]
[:Forecast, :AutoStation, :Aqi, :Warning]
end
Dir[File.join(File.dirname(__FILE__), 'source_schemas/*.rb')].each { |file|
......
module WeatherModel
module SourceSchema
AutoStationTenMins =
{
AutoStationTenMins = {
sort: 'AutoStation',
table_name: :auto_station_ten_mins,
schema: {
......
module WeatherModel
module SourceSchema
CityForecast =
{
CityForecast = {
sort: 'Forecast',
table_name: :city_forecasts,
schema: {
......
module WeatherModel
module SourceSchema
WarningDistrict = {
sort: 'Warning',
table_name: :warning_district,
schema: {
publishtime: :datetime,
warning_type: :string,
level: :string,
content: :string,
unit: :string
},
options: {
index: [:publishtime, :unit],
expire: 11 * 24 * 60 * 60,
unique: nil,
belongs_to: nil,
has_many: nil,
json_column: nil
},
factory_name: :warning_district,
factory: {
publishtime: Time.parse('2017-05-16 16:00'),
warning_type: "雷电",
level: "解除",
content: "据最新气象资料分析,目前影响本地的雷暴已经明显减弱,本地雷电黄色预警信号解除。",
unit: "宝山"
}
}
end
end
\ No newline at end of file
......@@ -113,6 +113,7 @@ RSpec.describe WeatherModel do
WeatherModel::AutoStation::AutoStationTenMins,
WeatherModel::Aqi::AqiForecast,
WeatherModel::Aqi::AqiLive,
WeatherModel::Warning::WarningDistrict
].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