Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
smogonet
Project
Project
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dominik Rosiek
smogonet
Commits
c6dcfd09
Commit
c6dcfd09
authored
Dec 13, 2016
by
Dominik Rosiek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
it works!
parent
2932d3dc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
8 deletions
+21
-8
db.py
db.py
+1
-0
measurement_viewer.py
measurement_viewer.py
+3
-5
models.py
models.py
+17
-3
No files found.
db.py
View file @
c6dcfd09
...
@@ -203,6 +203,7 @@ class DDBTable(object):
...
@@ -203,6 +203,7 @@ class DDBTable(object):
message
=
yield
gen
.
Task
(
self
.
_dynamodb
(
operation
=
'Scan'
)
.
call
,
message
=
yield
gen
.
Task
(
self
.
_dynamodb
(
operation
=
'Scan'
)
.
call
,
TableName
=
self
.
_get_table_name
())
TableName
=
self
.
_get_table_name
())
data
=
[
self
.
decode_item
(
item
=
item
)
for
item
in
message
[
'Items'
]]
data
=
[
self
.
decode_item
(
item
=
item
)
for
item
in
message
[
'Items'
]]
raise
gen
.
Return
(
data
)
raise
gen
.
Return
(
data
)
...
...
measurement_viewer.py
View file @
c6dcfd09
...
@@ -18,12 +18,10 @@ class MainHandler(tornado.web.RequestHandler):
...
@@ -18,12 +18,10 @@ class MainHandler(tornado.web.RequestHandler):
#stations = self.get_stations()
#stations = self.get_stations()
#stations = models.Station.get_all()
#stations = models.Station.get_all()
#stations = models.Station.getall()
#stations = models.Station.getall()
stations
=
yield
models
.
Station
.
get
(
"b1d12bb6-a3b7-43b8-b6ab-6d6e62cb794e"
)
stations
=
yield
models
.
Station
.
get_all
()
s
=
stations
.
result
()
measurement
=
yield
models
.
Measurement
.
get
(
"5c2be10b-5d33-47d7-95fe-b3f6fc29a3af"
)
measurement
=
yield
models
.
Measurement
.
get
(
"5c2be10b-5d33-47d7-95fe-b3f6fc29a3af"
)
m
=
measurement
.
result
()
for
s
in
stations
:
self
.
write
(
"{0} {1} {2} {3} {4}<br />"
.
format
(
s
.
id
,
s
.
city
,
s
.
longitude
,
s
.
latitude
,
s
.
name
))
self
.
write
(
"{0} {1} {2} {3} {4}<br />"
.
format
(
s
.
id
,
s
.
city
,
s
.
longitude
,
s
.
latitude
,
s
.
name
))
# measurement = models.Measurement.getlast(station=s.id)
# measurement = models.Measurement.getlast(station=s.id)
...
...
models.py
View file @
c6dcfd09
...
@@ -9,7 +9,6 @@ from tornado.ioloop import IOLoop
...
@@ -9,7 +9,6 @@ from tornado.ioloop import IOLoop
class
DDBobject
(
object
):
class
DDBobject
(
object
):
@
classmethod
@
classmethod
@
coroutine
def
from_dict
(
cls
,
data
):
def
from_dict
(
cls
,
data
):
return
cls
(
**
data
)
return
cls
(
**
data
)
...
@@ -39,6 +38,16 @@ class Station(DDBobject):
...
@@ -39,6 +38,16 @@ class Station(DDBobject):
result
=
yield
DDBstations
()
.
add
(
station
=
self
)
result
=
yield
DDBstations
()
.
add
(
station
=
self
)
return
result
return
result
@
classmethod
@
coroutine
def
get_all
(
cls
):
data
=
yield
DDBstations
()
.
get_all
()
return_value
=
[]
for
station
in
data
:
return_value
.
append
(
cls
.
from_dict
(
station
))
return
return_value
class
Type
(
DDBobject
):
class
Type
(
DDBobject
):
stored
=
{}
stored
=
{}
...
@@ -84,11 +93,11 @@ class Measurement(DDBobject):
...
@@ -84,11 +93,11 @@ class Measurement(DDBobject):
data
=
yield
DDBmeasurements
()
.
get
(
measurement_id
)
data
=
yield
DDBmeasurements
()
.
get
(
measurement_id
)
station
=
yield
Station
.
get
(
data
[
'station_id'
])
station
=
yield
Station
.
get
(
data
[
'station_id'
])
data
[
'station'
]
=
station
.
result
()
data
[
'station'
]
=
station
del
data
[
'station_id'
]
del
data
[
'station_id'
]
pollution_type
=
yield
Type
.
get
(
data
[
'type_id'
])
pollution_type
=
yield
Type
.
get
(
data
[
'type_id'
])
data
[
'pollution_type'
]
=
pollution_type
.
result
()
data
[
'pollution_type'
]
=
pollution_type
del
data
[
'type_id'
]
del
data
[
'type_id'
]
return
cls
.
from_dict
(
data
)
return
cls
.
from_dict
(
data
)
...
@@ -97,3 +106,8 @@ class Measurement(DDBobject):
...
@@ -97,3 +106,8 @@ class Measurement(DDBobject):
def
save
(
self
):
def
save
(
self
):
result
=
yield
DDBmeasurements
()
.
add
(
measurement
=
self
)
result
=
yield
DDBmeasurements
()
.
add
(
measurement
=
self
)
return
result
return
result
@
coroutine
def
get_last
(
self
,
station_id
):
# TODO
pass
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