Commit b6a7f1dc by ivan Lan

Add AutoStation

parent fba839d2
class CreateTenMinAutoStations < ActiveRecord::Migration[5.0]
def up
create_table :auto_station_ten_mins do |t|
t.datetime :datetime
t.string :sitenumber
t.string :name
t.string :tempe
t.string :rain
t.string :wind_direction
t.string :wind_speed
t.string :visibility
t.string :humi
t.string :max_tempe
t.string :min_tempe
t.string :max_speed
t.string :max_direction
t.string :pressure
t.timestamps
end
add_index :auto_station_ten_mins, :datetime
add_index :auto_station_ten_mins, :sitenumber
end
def down
drop_table :auto_station_ten_mins
end
end
......@@ -2,42 +2,13 @@ module WeatherModel
module SourceSchema
def self.sorts
['Forecast']
[:Forecast, :AutoStation]
end
CityForecast = {
sort: 'Forecast',
table_name: :city_forecasts,
schema: {
date: :date,
cityname: :string,
temp_high: :string,
temp_low: :string,
weather_text: :string,
weather_pic: :string,
win_dir: :string,
win_speed: :string,
},
options: {
index: [:cityname, :date],
expire: 1,
unique: :mysql_id,
father: nil,
son: nil,
},
factory_name: :forecast_shanghai_ten,
factory: {
datetime: '2017-05-16',
cityname: 'shanghai',
temp_high: '100',
temp_low: '0',
weather_text: '酷热严寒',
weather_pic: 'http://xxx.com',
win_dir: '东南西北风',
win_speed: '1级',
}
Dir['./lib/weather-model/source_schemas/*.rb'].each { |file|
require file
}
end
end
module WeatherModel
module SourceSchema
TenMins =
{
sort: 'AutoStation',
table_name: :auto_stations_ten_mins,
schema: {
datetime: :datetime,
sitenumber: :string,
name: :string,
tempe: :string,
rain: :string,
wind_direction: :string,
wind_speed: :string,
visibility: :string,
humi: :string,
max_tempe: :string,
min_tempe: :string,
max_speed: :string,
max_direction: :string,
pressure: :string,
},
options: {
index: %i[datetime sitenumber],
expire: 4 * 60 * 60,
unique: nil,
father: nil,
son: nil,
},
factory_name: :auto_station_ten_min,
factory: {
datetime: Time.parse('2011-11-11 11:11'),
sitenumber: '99632',
name: '蓬莱公园',
tempe: '25.6',
rain: '0',
wind_direction: '226',
wind_speed: '0.3',
visibility: '////',
humi: '////',
max_tempe: '25.6',
min_tempe: '24.3',
max_speed: '3.1',
max_direction: '308',
pressure: '////',
}
}
end
end
module WeatherModel
module SourceSchema
CityForecast =
{
sort: 'Forecast',
table_name: :city_forecasts,
schema: {
date: :date,
cityname: :string,
temp_high: :string,
temp_low: :string,
weather_text: :string,
weather_pic: :string,
win_dir: :string,
win_speed: :string,
},
options: {
index: [:cityname, :date],
expire: 11 * 24 * 60 * 60,
unique: nil,
father: nil,
son: nil,
},
factory_name: :city_forecast,
factory: {
date: Time.parse('2017-05-16'),
cityname: '上海',
temp_high: '100',
temp_low: '0',
weather_text: '酷热严寒',
weather_pic: 'http://xxx.com',
win_dir: '东南西北风',
win_speed: '1级',
}
}
end
end
\ No newline at end of file
......@@ -37,6 +37,8 @@ module WeatherModel
attribute :mysql_id
attribute :updated_at
index :mysql_id
unique :mysql_id
settings[:schema].keys.each { |attr|
attribute attr
}
......
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