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
b1e5b04d
Commit
b1e5b04d
authored
May 20, 2017
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Aqi::Forecast
parent
afebacf0
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
5 deletions
+79
-5
1_create_city_forecasts.rb
db/migrate/1_create_city_forecasts.rb
+1
-1
3_create_aqi_forecasts.rb
db/migrate/3_create_aqi_forecasts.rb
+18
-0
source_schema.rb
lib/weather-model/source_schema.rb
+1
-1
aqi.rb
lib/weather-model/source_schemas/aqi.rb
+56
-0
forecast.rb
lib/weather-model/source_schemas/forecast.rb
+2
-2
weather-model_spec.rb
spec/weather-model_spec.rb
+1
-1
No files found.
db/migrate/1_create_city_forecasts.rb
View file @
b1e5b04d
class
CreateCityForecasts
<
ActiveRecord
::
Migration
[
5.0
]
def
up
create_table
:city_forecasts
do
|
t
|
t
.
date
:dat
e
t
.
date
time
:datetim
e
t
.
integer
:temp_low
t
.
integer
:temp_high
t
.
string
:weather_text
...
...
db/migrate/3_create_aqi_forecasts.rb
0 → 100644
View file @
b1e5b04d
class
CreateAqiForecasts
<
ActiveRecord
::
Migration
[
5.0
]
def
up
create_table
:aqi_forecasts
do
|
t
|
t
.
datetime
:datetime
t
.
string
:prompt
t
.
text
:list
t
.
timestamps
end
add_index
:aqi_forecasts
,
:datetime
end
def
down
drop_table
:aqi_forecasts
end
end
lib/weather-model/source_schema.rb
View file @
b1e5b04d
...
...
@@ -2,7 +2,7 @@ module WeatherModel
module
SourceSchema
def
self
.
sorts
[
:Forecast
,
:AutoStation
]
[
:Forecast
,
:AutoStation
,
:Aqi
]
end
Dir
[
'./lib/weather-model/source_schemas/*.rb'
].
each
{
|
file
|
...
...
lib/weather-model/source_schemas/aqi.rb
0 → 100644
View file @
b1e5b04d
module
WeatherModel
module
SourceSchema
Forecast
=
{
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_columns: :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"
}
]
}
}
end
end
\ No newline at end of file
lib/weather-model/source_schemas/forecast.rb
View file @
b1e5b04d
...
...
@@ -5,7 +5,7 @@ module WeatherModel
sort:
'Forecast'
,
table_name: :city_forecasts
,
schema:
{
date
: :dat
e
,
date
time: :datetim
e
,
cityname: :string
,
temp_high: :string
,
temp_low: :string
,
...
...
@@ -24,7 +24,7 @@ module WeatherModel
},
factory_name: :city_forecast
,
factory:
{
date
:
Time
.
parse
(
'2017-05-16
'
),
date
time:
Time
.
parse
(
'2017-05-16 16:00
'
),
cityname:
'上海'
,
temp_high:
'100'
,
temp_low:
'0'
,
...
...
spec/weather-model_spec.rb
View file @
b1e5b04d
...
...
@@ -41,7 +41,7 @@ RSpec.describe WeatherModel do
@expire
=
1
Forecast
::
CityForecast
::
Ohm
.
expire
@expire
mysql_obj
=
Forecast
::
CityForecast
.
create
({
date:
'2017-05-16'
,
date
time
:
'2017-05-16'
,
cityname:
'shanghai'
,
temp_high:
'100'
,
temp_low:
'0'
,
...
...
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