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
c643194e
Commit
c643194e
authored
1 month ago
by
Gezer
Browse files
Options
Download
Email Patches
Plain Diff
Added List Room Endpoint
parent
c9afe0b0
main
backup_aaron
backup_ade
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
backend/app/urls.py
+2
-0
backend/app/urls.py
backend/app/views.py
+18
-0
backend/app/views.py
with
20 additions
and
0 deletions
+20
-0
backend/app/urls.py
+
2
-
0
View file @
c643194e
...
...
@@ -7,4 +7,6 @@ urlpatterns = [
path
(
"api/logout"
,
views
.
logout_view
,
name
=
"logout"
),
path
(
"api/user"
,
views
.
user
,
name
=
"user"
),
path
(
"api/register"
,
views
.
register
,
name
=
"register"
),
path
(
"api/room_data_range"
,
views
.
room_data_range
,
name
=
"room_data_range"
),
path
(
"api/get_rooms"
,
views
.
get_rooms
,
name
=
"get_rooms"
),
]
This diff is collapsed.
Click to expand it.
backend/app/views.py
+
18
-
0
View file @
c643194e
...
...
@@ -102,3 +102,21 @@ def room_data_range(request):
return
JsonResponse
(
{
"success"
:
False
,
"message"
:
"Invalid JSON"
},
status
=
400
)
@
require_http_methods
([
"GET"
])
def
get_rooms
(
request
):
client
=
InfluxDBHelper
(
url
=
os
.
getenv
(
"INFLUXDB_URL"
),
token
=
os
.
getenv
(
"INFLUXDB_TOKEN"
),
org
=
os
.
getenv
(
"INFLUXDB_ORG"
),
bucket
=
os
.
getenv
(
"INFLUXDB_BUCKET"
),
)
tables
=
client
.
list_rooms
()
rooms
=
set
()
for
table
in
tables
:
for
record
in
table
.
records
:
rooms
.
add
(
record
.
get_value
())
return
JsonResponse
({
"rooms"
:
sorted
(
rooms
)})
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