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
b3b6e42c
Commit
b3b6e42c
authored
May 22, 2017
by
Ivan Lan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'lan/add_warning_district' into 'master'
Add warning_district See merge request
!15
parents
0b4ba35b
0afaa0cc
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
124 additions
and
78 deletions
+124
-78
5_create_warning_district.rb
db/migrate/5_create_warning_district.rb
+19
-0
source_schema.rb
lib/weather-model/source_schema.rb
+1
-1
auto_station.rb
lib/weather-model/source_schemas/auto_station.rb
+40
-41
forecast.rb
lib/weather-model/source_schemas/forecast.rb
+35
-35
warning.rb
lib/weather-model/source_schemas/warning.rb
+28
-1
weather-model_spec.rb
spec/weather-model_spec.rb
+1
-0
No files found.
db/migrate/5_create_warning_district.rb
0 → 100644
View file @
b3b6e42c
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
lib/weather-model/source_schema.rb
View file @
b3b6e42c
...
@@ -2,7 +2,7 @@ module WeatherModel
...
@@ -2,7 +2,7 @@ module WeatherModel
module
SourceSchema
module
SourceSchema
def
self
.
sorts
def
self
.
sorts
[
:Forecast
,
:AutoStation
,
:Aqi
]
[
:Forecast
,
:AutoStation
,
:Aqi
,
:Warning
]
end
end
Dir
[
File
.
join
(
File
.
dirname
(
__FILE__
),
'source_schemas/*.rb'
)].
each
{
|
file
|
Dir
[
File
.
join
(
File
.
dirname
(
__FILE__
),
'source_schemas/*.rb'
)].
each
{
|
file
|
...
...
lib/weather-model/source_schemas/auto_station.rb
View file @
b3b6e42c
module
WeatherModel
module
WeatherModel
module
SourceSchema
module
SourceSchema
AutoStationTenMins
=
AutoStationTenMins
=
{
{
sort:
'AutoStation'
,
sort:
'AutoStation'
,
table_name: :auto_station_ten_mins
,
table_name: :auto_station_ten_mins
,
schema:
{
schema:
{
datetime: :datetime
,
datetime: :datetime
,
sitenumber: :string
,
sitenumber: :string
,
name: :string
,
name: :string
,
tempe: :string
,
tempe: :string
,
rain: :string
,
rain: :string
,
wind_direction: :string
,
wind_direction: :string
,
wind_speed: :string
,
wind_speed: :string
,
visibility: :string
,
visibility: :string
,
humi: :string
,
humi: :string
,
max_tempe: :string
,
max_tempe: :string
,
min_tempe: :string
,
min_tempe: :string
,
max_speed: :string
,
max_speed: :string
,
max_direction: :string
,
max_direction: :string
,
pressure: :string
,
pressure: :string
,
},
},
options:
{
options:
{
index:
%i[datetime name]
,
index:
%i[datetime name]
,
expire:
4
*
60
*
60
,
expire:
4
*
60
*
60
,
},
},
factory_name: :auto_station_ten_min
,
factory_name: :auto_station_ten_min
,
factory:
{
factory:
{
datetime:
Time
.
parse
(
'2011-11-11 11:11'
),
datetime:
Time
.
parse
(
'2011-11-11 11:11'
),
sitenumber:
'99632'
,
sitenumber:
'99632'
,
name:
'蓬莱公园'
,
name:
'蓬莱公园'
,
tempe:
'25.6'
,
tempe:
'25.6'
,
rain:
'0'
,
rain:
'0'
,
wind_direction:
'226'
,
wind_direction:
'226'
,
wind_speed:
'0.3'
,
wind_speed:
'0.3'
,
visibility:
'////'
,
visibility:
'////'
,
humi:
'////'
,
humi:
'////'
,
max_tempe:
'25.6'
,
max_tempe:
'25.6'
,
min_tempe:
'24.3'
,
min_tempe:
'24.3'
,
max_speed:
'3.1'
,
max_speed:
'3.1'
,
max_direction:
'308'
,
max_direction:
'308'
,
pressure:
'////'
,
pressure:
'////'
,
}
}
}
}
end
end
end
end
lib/weather-model/source_schemas/forecast.rb
View file @
b3b6e42c
module
WeatherModel
module
WeatherModel
module
SourceSchema
module
SourceSchema
CityForecast
=
CityForecast
=
{
{
sort:
'Forecast'
,
sort:
'Forecast'
,
table_name: :city_forecasts
,
table_name: :city_forecasts
,
schema:
{
schema:
{
datetime: :datetime
,
datetime: :datetime
,
cityname: :string
,
cityname: :string
,
temp_high: :string
,
temp_high: :string
,
temp_low: :string
,
temp_low: :string
,
weather_text1: :string
,
weather_text1: :string
,
weather_text2: :string
,
weather_text2: :string
,
weather_pic: :string
,
weather_pic: :string
,
win_dir: :string
,
win_dir: :string
,
win_speed: :string
,
win_speed: :string
,
},
},
options:
{
options:
{
index:
[
:cityname
,
:datetime
],
index:
[
:cityname
,
:datetime
],
expire:
11
*
24
*
60
*
60
,
expire:
11
*
24
*
60
*
60
,
unique:
nil
,
unique:
nil
,
belongs_to:
nil
,
belongs_to:
nil
,
has_many:
nil
,
has_many:
nil
,
json_column:
nil
json_column:
nil
},
},
factory_name: :city_forecast
,
factory_name: :city_forecast
,
factory:
{
factory:
{
datetime:
Time
.
parse
(
'2017-05-16 16:00'
),
datetime:
Time
.
parse
(
'2017-05-16 16:00'
),
cityname:
'上海'
,
cityname:
'上海'
,
temp_high:
'100'
,
temp_high:
'100'
,
temp_low:
'0'
,
temp_low:
'0'
,
weather_text1:
'酷热'
,
weather_text1:
'酷热'
,
weather_text2:
'严寒'
,
weather_text2:
'严寒'
,
weather_pic:
'http://xxx.com'
,
weather_pic:
'http://xxx.com'
,
win_dir:
'东南西北风'
,
win_dir:
'东南西北风'
,
win_speed:
'1级'
,
win_speed:
'1级'
,
}
}
}
}
end
end
end
end
\ No newline at end of file
lib/weather-model/source_schemas/warning.rb
View file @
b3b6e42c
module
WeatherModel
module
WeatherModel
module
SourceSchema
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
end
end
\ No newline at end of file
spec/weather-model_spec.rb
View file @
b3b6e42c
...
@@ -113,6 +113,7 @@ RSpec.describe WeatherModel do
...
@@ -113,6 +113,7 @@ RSpec.describe WeatherModel do
WeatherModel
::
AutoStation
::
AutoStationTenMins
,
WeatherModel
::
AutoStation
::
AutoStationTenMins
,
WeatherModel
::
Aqi
::
AqiForecast
,
WeatherModel
::
Aqi
::
AqiForecast
,
WeatherModel
::
Aqi
::
AqiLive
,
WeatherModel
::
Aqi
::
AqiLive
,
WeatherModel
::
Warning
::
WarningDistrict
].
each
{
|
source
|
].
each
{
|
source
|
# create factory
# create factory
source
.
all
;
source
.
const_get
(
'Ohm'
).
all
.
first
;
source
.
all
;
source
.
const_get
(
'Ohm'
).
all
.
first
;
...
...
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