Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel2
Web
Commits
ae3c6c7f
Commit
ae3c6c7f
authored
2 months ago
by
Gezer
Browse files
Options
Download
Email Patches
Plain Diff
modified json format for room data
parent
434b1c37
main
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
backend/app/views.py
+12
-10
backend/app/views.py
stream_processing/mac_to_room.json
+1
-1
stream_processing/mac_to_room.json
with
13 additions
and
11 deletions
+13
-11
backend/app/views.py
+
12
-
10
View file @
ae3c6c7f
...
@@ -93,18 +93,20 @@ def room_data_range(request):
...
@@ -93,18 +93,20 @@ def room_data_range(request):
)
)
tables
=
client
.
get_room_data_in_range
(
room
,
start
,
stop
)
tables
=
client
.
get_room_data_in_range
(
room
,
start
,
stop
)
results
=
[]
data_by_time
=
{}
for
table
in
tables
:
for
table
in
tables
:
for
record
in
table
.
records
:
for
record
in
table
.
records
:
results
.
append
(
timestamp
=
str
(
record
.
get_time
())
{
field
=
record
.
get_field
()
"time"
:
str
(
record
.
get_
tim
e
()
),
value
=
record
.
get_
valu
e
()
"field"
:
record
.
get_field
(),
"value"
:
record
.
get_value
(),
if
timestamp
not
in
data_by_time
:
}
data_by_time
[
timestamp
]
=
{
}
)
data_by_time
[
timestamp
][
field
]
=
value
return
JsonResponse
({
"room"
:
room
,
"data"
:
results
},
status
=
200
)
return
JsonResponse
({
"room"
:
room
,
"data"
:
data_by_time
},
status
=
200
)
except
json
.
JSONDecodeError
:
except
json
.
JSONDecodeError
:
return
JsonResponse
(
return
JsonResponse
(
{
"success"
:
False
,
"message"
:
"Invalid JSON"
},
status
=
400
{
"success"
:
False
,
"message"
:
"Invalid JSON"
},
status
=
400
...
...
This diff is collapsed.
Click to expand it.
stream_processing/mac_to_room.json
+
1
-
1
View file @
ae3c6c7f
{
{
"AA:BB:CC:DD:EE:FF"
:
"
Wohnzimmer
"
,
"AA:BB:CC:DD:EE:FF"
:
"
1/121
"
,
"11:22:33:44:55:66"
:
"K
\u
00fcche"
,
"11:22:33:44:55:66"
:
"K
\u
00fcche"
,
"77:88:99:AA:BB:CC"
:
"Schlafzimmer"
,
"77:88:99:AA:BB:CC"
:
"Schlafzimmer"
,
"DE:AD:BE:EF:12:34"
:
""
,
"DE:AD:BE:EF:12:34"
:
""
,
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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
Menu
Explore
Projects
Groups
Snippets