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
f5b90da8
Commit
f5b90da8
authored
Dec 20, 2016
by
Dominik Rosiek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
soft cache ftw
parent
1dbe5473
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
21 deletions
+29
-21
db.py
db.py
+8
-12
measurement_viewer.py
measurement_viewer.py
+4
-8
models.py
models.py
+17
-1
No files found.
db.py
View file @
f5b90da8
...
@@ -2,12 +2,8 @@ import logging
...
@@ -2,12 +2,8 @@ import logging
import
re
import
re
import
six
import
six
import
uuid
from
functools
import
partial
from
tornado
import
gen
from
tornado
import
gen
from
tornado.ioloop
import
IOLoop
from
tornado_botocore
import
Botocore
from
tornado_botocore
import
Botocore
...
@@ -213,8 +209,8 @@ class DDBstations(DDBTable):
...
@@ -213,8 +209,8 @@ class DDBstations(DDBTable):
'KeyType'
:
'HASH'
,
'KeyType'
:
'HASH'
,
}]
}]
PROVISIONED_THROUGHPUT
=
{
PROVISIONED_THROUGHPUT
=
{
'ReadCapacityUnits'
:
1
,
'ReadCapacityUnits'
:
20
,
'WriteCapacityUnits'
:
1
'WriteCapacityUnits'
:
5
}
}
FIELDS
=
{
FIELDS
=
{
'station_id'
:
DDBUUIDField
,
'station_id'
:
DDBUUIDField
,
...
@@ -258,8 +254,8 @@ class DDBtypes(DDBTable):
...
@@ -258,8 +254,8 @@ class DDBtypes(DDBTable):
'KeyType'
:
'HASH'
,
'KeyType'
:
'HASH'
,
}]
}]
PROVISIONED_THROUGHPUT
=
{
PROVISIONED_THROUGHPUT
=
{
'ReadCapacityUnits'
:
1
,
'ReadCapacityUnits'
:
20
,
'WriteCapacityUnits'
:
1
'WriteCapacityUnits'
:
5
}
}
FIELDS
=
{
FIELDS
=
{
'type_id'
:
DDBUUIDField
,
'type_id'
:
DDBUUIDField
,
...
@@ -303,8 +299,8 @@ class DDBmeasurements(DDBTable):
...
@@ -303,8 +299,8 @@ class DDBmeasurements(DDBTable):
'KeyType'
:
'HASH'
,
'KeyType'
:
'HASH'
,
}]
}]
PROVISIONED_THROUGHPUT
=
{
PROVISIONED_THROUGHPUT
=
{
'ReadCapacityUnits'
:
1
,
'ReadCapacityUnits'
:
50
,
'WriteCapacityUnits'
:
1
'WriteCapacityUnits'
:
5
}
}
FIELDS
=
{
FIELDS
=
{
'measurement_id'
:
DDBUUIDField
,
'measurement_id'
:
DDBUUIDField
,
...
@@ -350,8 +346,8 @@ class DDBlastmeasurements(DDBTable):
...
@@ -350,8 +346,8 @@ class DDBlastmeasurements(DDBTable):
'KeyType'
:
'HASH'
,
'KeyType'
:
'HASH'
,
}]
}]
PROVISIONED_THROUGHPUT
=
{
PROVISIONED_THROUGHPUT
=
{
'ReadCapacityUnits'
:
1
,
'ReadCapacityUnits'
:
50
,
'WriteCapacityUnits'
:
1
'WriteCapacityUnits'
:
5
}
}
FIELDS
=
{
FIELDS
=
{
'station_id'
:
DDBUUIDField
,
'station_id'
:
DDBUUIDField
,
...
...
measurement_viewer.py
View file @
f5b90da8
...
@@ -11,15 +11,11 @@ class MainHandler(tornado.web.RequestHandler):
...
@@ -11,15 +11,11 @@ class MainHandler(tornado.web.RequestHandler):
def
get
(
self
):
def
get
(
self
):
stations
=
yield
models
.
Station
.
get_all
()
stations
=
yield
models
.
Station
.
get_all
()
pollutions
=
yield
models
.
Type
.
get_all
()
pollutions
=
yield
models
.
Type
.
get_all
()
last_measurements
=
yield
models
.
Measurement
.
get_all_last
()
for
station
in
stations
.
values
():
for
measurement
in
last_measurements
:
for
pollution
in
pollutions
.
values
():
try
:
self
.
write
(
"
\n
"
)
measurement
=
yield
models
.
Measurement
.
get_last
(
station
,
pollution
)
self
.
write
(
str
(
measurement
))
self
.
write
(
str
(
measurement
))
except
:
self
.
write
(
"
\n
"
)
pass
def
make_app
():
def
make_app
():
...
...
models.py
View file @
f5b90da8
...
@@ -91,6 +91,7 @@ class Type(DDBobject):
...
@@ -91,6 +91,7 @@ class Type(DDBobject):
class
Measurement
(
DDBobject
):
class
Measurement
(
DDBobject
):
stored
=
{}
stored
=
{}
last_measurements
=
{}
def
__init__
(
self
,
station
,
pollution_type
,
value
,
time
,
measurement_id
=
None
):
def
__init__
(
self
,
station
,
pollution_type
,
value
,
time
,
measurement_id
=
None
):
self
.
id
=
measurement_id
or
str
(
uuid
.
uuid4
())
self
.
id
=
measurement_id
or
str
(
uuid
.
uuid4
())
...
@@ -115,7 +116,9 @@ class Measurement(DDBobject):
...
@@ -115,7 +116,9 @@ class Measurement(DDBobject):
data
[
'pollution_type'
]
=
pollution_type
data
[
'pollution_type'
]
=
pollution_type
del
data
[
'type_id'
]
del
data
[
'type_id'
]
return
cls
.
from_dict
(
data
)
return_value
=
cls
.
from_dict
(
data
)
cls
.
stored
[
return_value
.
id
]
=
return_value
return
return_value
@
coroutine
@
coroutine
def
save
(
self
):
def
save
(
self
):
...
@@ -130,5 +133,18 @@ class Measurement(DDBobject):
...
@@ -130,5 +133,18 @@ class Measurement(DDBobject):
return_value
=
yield
cls
.
get
(
measurement_id
=
data
[
'measurement_id'
])
return_value
=
yield
cls
.
get
(
measurement_id
=
data
[
'measurement_id'
])
return
return_value
return
return_value
@
classmethod
@
coroutine
def
get_all_last
(
cls
):
data
=
yield
DDBlastmeasurements
()
.
get_all
()
return_value
=
[]
cls
.
last_measurements
=
None
for
measurement
in
data
:
get
=
yield
cls
.
get
(
measurement
[
'measurement_id'
])
return_value
.
append
(
get
)
cls
.
last_measurements
=
return_value
return
cls
.
last_measurements
def
__str__
(
self
):
def
__str__
(
self
):
return
"{0} {1} {2} {3} {4}"
.
format
(
self
.
id
,
self
.
station
.
id
,
self
.
type
.
id
,
self
.
value
,
self
.
time
)
return
"{0} {1} {2} {3} {4}"
.
format
(
self
.
id
,
self
.
station
.
id
,
self
.
type
.
id
,
self
.
value
,
self
.
time
)
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