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
2a05ea07
Commit
2a05ea07
authored
Jun 01, 2017
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Other::WeatherIndex
parent
a0f74c90
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
2 deletions
+47
-2
6_create_weather_index.rb
db/migrate/6_create_weather_index.rb
+17
-0
source_schema.rb
lib/weather-model/source_schema.rb
+1
-1
other.rb
lib/weather-model/source_schemas/other.rb
+27
-0
weather-model_spec.rb
spec/weather-model_spec.rb
+2
-1
No files found.
db/migrate/6_create_weather_index.rb
0 → 100644
View file @
2a05ea07
class
CreateWeatherIndex
<
ActiveRecord
::
Migration
[
5.0
]
def
up
create_table
:weather_index
do
|
t
|
t
.
datetime
:publishtime
t
.
string
:type
t
.
text
:list
t
.
timestamps
end
add_index
:weather_index
,
:publishtime
end
def
down
drop_table
:weather_index
end
end
lib/weather-model/source_schema.rb
View file @
2a05ea07
...
...
@@ -2,7 +2,7 @@ module WeatherModel
module
SourceSchema
def
self
.
sorts
[
:Forecast
,
:AutoStation
,
:Aqi
,
:Warning
]
[
:Forecast
,
:AutoStation
,
:Aqi
,
:Warning
,
:Other
]
end
Dir
[
File
.
join
(
File
.
dirname
(
__FILE__
),
'source_schemas/*.rb'
)].
each
{
|
file
|
...
...
lib/weather-model/source_schemas/other.rb
0 → 100644
View file @
2a05ea07
module
WeatherModel
module
SourceSchema
WeatherIndex
=
{
sort:
'Other'
,
table_name: :weather_index
,
schema:
{
publishtime: :datetime
,
type: :string
,
list: :text
},
options:
{
index:
[
:publishtime
],
expire:
3
*
24
*
60
*
60
,
json_column: :list
},
factory_name: :weather_index
,
factory:
{
publishtime:
Time
.
parse
(
'2017-05-16 16:00'
),
warning_type:
"雷电"
,
list:
[
{
:detail
=>
"日照强度强,外出需加强防护。"
,
:id
=>
"1"
,
:level
=>
"3级"
,
:mean
=>
"加强防护"
,
:name
=>
"日照指数"
,
:shortcues
=>
"强"
,
:time
=>
"2017-06-02"
},
{
:detail
=>
"气温适宜,人体感觉略偏暖,较为舒适。"
,
:id
=>
"2"
,
:level
=>
"1级"
,
:mean
=>
"气温适宜,人体感觉略偏暖,较为舒适"
,
:name
=>
"体感指数(上午)"
,
:shortcues
=>
"较舒适"
,
:time
=>
"2017-06-02"
}
]
}
}
end
end
spec/weather-model_spec.rb
View file @
2a05ea07
...
...
@@ -113,7 +113,8 @@ RSpec.describe WeatherModel do
WeatherModel
::
AutoStation
::
AutoStationTenMins
,
WeatherModel
::
Aqi
::
AqiForecast
,
WeatherModel
::
Aqi
::
AqiLive
,
WeatherModel
::
Warning
::
WarningDistrict
WeatherModel
::
Warning
::
WarningDistrict
,
WeatherModel
::
Other
::
WeatherIndex
].
each
{
|
source
|
# create factory
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