Quota patch for videos

This commit is contained in:
Logan Cusano
2025-07-14 04:59:56 -04:00
parent d90a9c28ef
commit 2a5ca2c5a5

View File

@@ -91,13 +91,12 @@ async def get_random_unvoted_video(current_user: dict = Depends(is_user)):
Retrieves a random, unvoted video document from Firestore.
"""
db = get_db()
videos_stream = db.collection('videos').where('has_been_voted', '==', False).stream()
videos_stream = db.collection('videos').where('has_been_voted', '==', False).limit(1).stream()
unvoted_videos = [doc.to_dict() for doc in videos_stream]
if not unvoted_videos:
raise HTTPException(status_code=404, detail="No more videos to vote on!")
random_video_data = random.choice(unvoted_videos)
return Video(**random_video_data)
@@ -142,6 +141,7 @@ async def stream_video(video_id: str, current_user: dict = Depends(is_user)):
raise HTTPException(status_code=404, detail="Video not found")
full_path = os.path.join(VIDEO_DIRECTORY, video_doc.to_dict()["file_path"])
print(full_path)
if not os.path.exists(full_path):
raise HTTPException(status_code=404, detail="Video file not found on disk")