Skip to content

Commit

Permalink
return blocked sites
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshuamjv2 committed Oct 17, 2024
1 parent b6a4af8 commit 035c35a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
__pycache__/
.pytest_cache/
.vscode/
/__pycache__
Binary file modified sessions/__pycache__/routes.cpython-39.pyc
Binary file not shown.
12 changes: 10 additions & 2 deletions sessions/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,16 @@ async def get_sessions(user=Depends(get_current_user)):
async def get_active_sessions():
sessions = db["sessions"].find({"end_time": {"$gte": datetime.now(tz=timezone.utc)}})
if sessions:
return list(sessions)
return []
sessions = list(sessions)
for i in sessions:
if i["block_lists"]:
block_lists = db["block_lists"].find({"_id": {"$in": i["block_lists"]}})
if block_lists:
block_lists = list(block_lists)
for block_list in block_lists:
i["block_lists"] = block_list["entries"]
i["id"] = i.pop("_id")
return sessions


@router.get("/{id}", status_code=200)
Expand Down

0 comments on commit 035c35a

Please sign in to comment.