fixed some bugs
This commit is contained in:
@@ -1118,6 +1118,47 @@ class VideoRepository:
|
||||
).fetchall()
|
||||
return [dict(row) for row in rows]
|
||||
|
||||
def delete_user_result(self, user_id: str, attempt_id: str) -> Optional[Dict[str, Any]]:
|
||||
"""Delete one attempt owned by the user and return its stored audio filename."""
|
||||
with self._connect() as connection:
|
||||
row = connection.execute(
|
||||
"""
|
||||
SELECT audio_filename FROM attempts
|
||||
WHERE attempt_id = ? AND user_id = ?
|
||||
""",
|
||||
(attempt_id, user_id),
|
||||
).fetchone()
|
||||
if row is None:
|
||||
return None
|
||||
connection.execute(
|
||||
"DELETE FROM attempts WHERE attempt_id = ? AND user_id = ?",
|
||||
(attempt_id, user_id),
|
||||
)
|
||||
return {"audio_filename": row["audio_filename"]}
|
||||
|
||||
def delete_user_dub_share(self, user_id: str, share_id: str) -> Optional[List[str]]:
|
||||
"""Delete one dub share owned by the user and return stored audio filenames."""
|
||||
with self._connect() as connection:
|
||||
share = connection.execute(
|
||||
"SELECT share_id FROM dub_shares WHERE share_id = ? AND user_id = ?",
|
||||
(share_id, user_id),
|
||||
).fetchone()
|
||||
if share is None:
|
||||
return None
|
||||
filenames = [
|
||||
row["audio_filename"]
|
||||
for row in connection.execute(
|
||||
"SELECT audio_filename FROM dub_share_segments WHERE share_id = ?",
|
||||
(share_id,),
|
||||
).fetchall()
|
||||
]
|
||||
# Segments are removed by ON DELETE CASCADE.
|
||||
connection.execute(
|
||||
"DELETE FROM dub_shares WHERE share_id = ? AND user_id = ?",
|
||||
(share_id, user_id),
|
||||
)
|
||||
return filenames
|
||||
|
||||
def delete_video(self, video_hash: str) -> Optional[Dict[str, Any]]:
|
||||
video = self.get_video(video_hash)
|
||||
if video is None:
|
||||
|
||||
Reference in New Issue
Block a user