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
c9ef0d17
Commit
c9ef0d17
authored
May 21, 2017
by
liyijie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add AqiLive model
parent
7b0b87c6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
143 additions
and
82 deletions
+143
-82
4_create_city_aqi_lives.rb
db/migrate/4_create_city_aqi_lives.rb
+34
-0
aqi.rb
lib/weather-model/source_schemas/aqi.rb
+109
-82
No files found.
db/migrate/4_create_city_aqi_lives.rb
0 → 100644
View file @
c9ef0d17
class
CreateAqiLives
<
ActiveRecord
::
Migration
[
5.0
]
def
up
create_table
:aqi_lives
do
|
t
|
t
.
integer
:aqi
t
.
string
:area
t
.
float
:co
t
.
float
:co_24h
t
.
float
:no2
t
.
float
:no2_24h
t
.
float
:o3
t
.
float
:o3_24h
t
.
float
:o3_8h
t
.
float
:o3_8h_24h
t
.
float
:pm10
t
.
float
:pm10_24h
t
.
float
:pm2_5
t
.
float
:pm2_5_24h
t
.
string
:position_name
t
.
string
:primary_pollutant
t
.
string
:quality
t
.
float
:so2
t
.
float
:so2_24h
t
.
string
:station_code
t
.
datetime
:time_point
t
.
timestamps
end
end
def
down
drop_table
:aqi_lives
end
end
lib/weather-model/source_schemas/aqi.rb
View file @
c9ef0d17
module
WeatherModel
module
WeatherModel
module
SourceSchema
module
SourceSchema
AqiForecast
=
{
sort:
'Aqi'
,
table_name: :aqi_forecasts
,
schema:
{
datetime: :datetime
,
prompt: :string
,
list: :text
},
options:
{
index:
%i[datetime]
,
expire:
2
*
24
*
60
*
60
,
unique:
nil
,
belongs_to:
nil
,
has_many:
nil
,
json_column: :list
},
factory_name: :aqi_forecast
,
factory:
{
datetime:
Time
.
parse
(
'2011-11-11 11:11'
),
prompt:
''
,
list:
[
{
"period"
=>
"今天夜间(20时—06时)"
,
"aqi"
=>
"35-55"
,
"level"
=>
"优到良"
,
"pripoll"
=>
"PM10"
},
{
"period"
=>
"明天上午(06时—12时)"
,
"aqi"
=>
"35-55"
,
"level"
=>
"优到良"
,
"pripoll"
=>
"PM10"
},
{
"period"
=>
"明天下午(12时—20时)"
,
"aqi"
=>
"45-65"
,
"level"
=>
"优到良"
,
"pripoll"
=>
"O3"
},
{
"period"
=>
"明天夜间(20时—06时)"
,
"aqi"
=>
"35-55"
,
"level"
=>
"优到良"
,
"pripoll"
=>
"PM10"
},
{
"period"
=>
"后天白天(06时—20时)"
,
"aqi"
=>
"55-75"
,
"level"
=>
"良"
,
"pripoll"
=>
"O3"
}
]
}
}
RealtimeAqi
=
AqiForecast
=
{
{
sort:
'Aqi'
,
sort:
'Aqi'
,
table_name: :aqi_forecasts
,
table_name: :realtime_aqi
,
schema:
{
schema:
{
datetime: :datetime
,
datetime: :datetime
,
prompt: :string
,
aqi: :string
,
list: :text
level: :string
,
},
pripoll: :string
,
options:
{
content: :string
,
index:
%i[datetime]
,
measure: :string
,
expire:
2
*
24
*
60
*
60
,
},
unique:
nil
,
options:
{
belongs_to:
nil
,
index:
%i[datetime]
,
has_many:
nil
,
expire:
3
*
24
*
60
*
60
,
json_column: :list
unique:
nil
,
},
belongs_to:
nil
,
factory_name: :aqi_forecast
,
has_many:
nil
,
factory:
{
json_column: :msg
datetime:
Time
.
parse
(
'2011-11-11 11:11'
),
},
prompt:
''
,
factory_name: :realtime_aqi
,
list:
[
factory:
{
{
datetime:
Time
.
parse
(
'2011-11-11 11:11'
),
"period"
=>
"今天夜间(20时—06时)"
,
aqi:
'54'
,
"aqi"
=>
"35-55"
,
level:
'良'
,
"level"
=>
"优到良"
,
pripoll:
'PM10'
,
"pripoll"
=>
"PM10"
msg:
{
},
{
content:
'空气质量可接受,但某些污染物可能对极少数异常敏感人群健康有较弱影响。'
,
"period"
=>
"明天上午(06时—12时)"
,
measure:
'建议措施极少数异常敏感人群应减少户外活动。'
"aqi"
=>
"35-55"
,
"level"
=>
"优到良"
,
"pripoll"
=>
"PM10"
},
{
"period"
=>
"明天下午(12时—20时)"
,
"aqi"
=>
"45-65"
,
"level"
=>
"优到良"
,
"pripoll"
=>
"O3"
},
{
"period"
=>
"明天夜间(20时—06时)"
,
"aqi"
=>
"35-55"
,
"level"
=>
"优到良"
,
"pripoll"
=>
"PM10"
},
{
"period"
=>
"后天白天(06时—20时)"
,
"aqi"
=>
"55-75"
,
"level"
=>
"良"
,
"pripoll"
=>
"O3"
}
}
}
]
}
}
}
AqiLive
=
{
sort:
'Aqi'
,
table_name: :aqi_lives
,
schema:
{
aqi: :integer
,
area: :string
,
co: :float
,
co_24: :float
,
no2: :float
,
no2_24: :float
,
o3: :float
,
o3_24: :float
,
o3_8h: :float
,
o3_8h_24: :float
,
pm10: :float
,
pm10_24: :float
,
pm2_5: :float
,
pm2_5_24: :float
,
position_name: :string
,
primary_pollutant: :string
,
quality: :string
,
so2: :float
,
so2_24h: :float
,
station_code: :string
,
time_point: :dateime
,
},
options:
{
index:
%i[area, time_point]
,
expire:
2
*
24
*
60
*
60
,
unique:
nil
,
belongs_to:
nil
,
has_many:
nil
,
json_column: :nil
,
},
factory_name: :aqi_live
,
factory:
{
"aqi"
=>
46
,
"area"
=>
"宜宾"
,
"co"
=>
1.1
,
"co_24h"
=>
1.2
,
"no2"
=>
20
,
"no2_24h"
=>
22
,
"o3"
=>
73
,
"o3_24h"
=>
129
,
"o3_8h"
=>
45
,
"o3_8h_24h"
=>
53
,
"pm10"
=>
45
,
"pm10_24h"
=>
60
,
"pm2_5"
=>
32
,
"pm2_5_24h"
=>
42
,
"position_name"
=>
"市政府"
,
"primary_pollutant"
=>
null
,
"quality"
=>
"优"
,
"so2"
=>
10
,
"so2_24h"
=>
13
,
"station_code"
=>
"1885A"
,
"time_point"
=>
"2017-05-21T16:00:00Z"
,
},
}
end
end
end
end
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