Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
weather-model
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
weather-model
Commits
b6a7f1dc
Commit
b6a7f1dc
authored
May 20, 2017
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add AutoStation
parent
fba839d2
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
124 additions
and
33 deletions
+124
-33
2_create_auto_station_ten_mins.rb
db/migrate/2_create_auto_station_ten_mins.rb
+30
-0
source_schema.rb
lib/weather-model/source_schema.rb
+4
-33
autostation.rb
lib/weather-model/source_schemas/autostation.rb
+49
-0
forecast.rb
lib/weather-model/source_schemas/forecast.rb
+39
-0
storer.rb
lib/weather-model/storer.rb
+2
-0
No files found.
db/migrate/2_create_auto_station_ten_mins.rb
0 → 100644
View file @
b6a7f1dc
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
lib/weather-model/source_schema.rb
View file @
b6a7f1dc
...
...
@@ -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
lib/weather-model/source_schemas/autostation.rb
0 → 100644
View file @
b6a7f1dc
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
lib/weather-model/source_schemas/forecast.rb
0 → 100644
View file @
b6a7f1dc
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
lib/weather-model/storer.rb
View file @
b6a7f1dc
...
...
@@ -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
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment