SHAFI commited on
Commit ·
56c77c8
1
Parent(s): 32e07da
solved audio and text summery saving error
Browse files- app/routes/audio.py +2 -2
- app/routes/news.py +1 -1
- app/services/appwrite_db.py +7 -3
- app/utils/cursor_pagination.py +2 -2
app/routes/audio.py
CHANGED
|
@@ -248,13 +248,13 @@ async def generate_audio_summary(request: AudioGenerationRequest):
|
|
| 248 |
collection_id=found_collection_id,
|
| 249 |
document_id=article_id,
|
| 250 |
audio_url=audio_url,
|
| 251 |
-
text_summary=
|
| 252 |
)
|
| 253 |
|
| 254 |
return AudioResponse(
|
| 255 |
success=True,
|
| 256 |
audio_url=audio_url,
|
| 257 |
-
text_summary=
|
| 258 |
message="Audio generated successfully"
|
| 259 |
)
|
| 260 |
|
|
|
|
| 248 |
collection_id=found_collection_id,
|
| 249 |
document_id=article_id,
|
| 250 |
audio_url=audio_url,
|
| 251 |
+
text_summary=text_summary# Pass generated summary (fix: use 'summary' var, not 'text_summary')
|
| 252 |
)
|
| 253 |
|
| 254 |
return AudioResponse(
|
| 255 |
success=True,
|
| 256 |
audio_url=audio_url,
|
| 257 |
+
text_summary=text_summary,
|
| 258 |
message="Audio generated successfully"
|
| 259 |
)
|
| 260 |
|
app/routes/news.py
CHANGED
|
@@ -90,7 +90,7 @@ async def get_news_by_category(
|
|
| 90 |
]
|
| 91 |
|
| 92 |
# Apply category filter logic (same as CursorPagination)
|
| 93 |
-
if category
|
| 94 |
queries.insert(0, Query.equal('category', category))
|
| 95 |
else:
|
| 96 |
# Default: Cursor Pagination (Preferred)
|
|
|
|
| 90 |
]
|
| 91 |
|
| 92 |
# Apply category filter logic (same as CursorPagination)
|
| 93 |
+
if category not in ('research', 'data-articles'):
|
| 94 |
queries.insert(0, Query.equal('category', category))
|
| 95 |
else:
|
| 96 |
# Default: Cursor Pagination (Preferred)
|
app/services/appwrite_db.py
CHANGED
|
@@ -677,17 +677,21 @@ class AppwriteDatabase:
|
|
| 677 |
logger.error(f"❌ [Appwrite] Error finding subscriber by token: {e}")
|
| 678 |
return None
|
| 679 |
|
| 680 |
-
async def update_article_audio(self, collection_id: str, document_id: str, audio_url: str) -> bool:
|
| 681 |
-
"""Update article with audio URL"""
|
| 682 |
if not self.initialized:
|
| 683 |
return False
|
| 684 |
|
| 685 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 686 |
await self.tablesDB.update_row(
|
| 687 |
database_id=settings.APPWRITE_DATABASE_ID,
|
| 688 |
collection_id=collection_id,
|
| 689 |
document_id=document_id,
|
| 690 |
-
data=
|
| 691 |
)
|
| 692 |
return True
|
| 693 |
except Exception as e:
|
|
|
|
| 677 |
logger.error(f"❌ [Appwrite] Error finding subscriber by token: {e}")
|
| 678 |
return None
|
| 679 |
|
| 680 |
+
async def update_article_audio(self, collection_id: str, document_id: str, audio_url: str, text_summary: Optional[str] = None) -> bool:
|
| 681 |
+
"""Update article with audio URL and optional text summary"""
|
| 682 |
if not self.initialized:
|
| 683 |
return False
|
| 684 |
|
| 685 |
try:
|
| 686 |
+
data = {'audio_url': audio_url}
|
| 687 |
+
if text_summary:
|
| 688 |
+
data['text_summary'] = text_summary
|
| 689 |
+
|
| 690 |
await self.tablesDB.update_row(
|
| 691 |
database_id=settings.APPWRITE_DATABASE_ID,
|
| 692 |
collection_id=collection_id,
|
| 693 |
document_id=document_id,
|
| 694 |
+
data=data
|
| 695 |
)
|
| 696 |
return True
|
| 697 |
except Exception as e:
|
app/utils/cursor_pagination.py
CHANGED
|
@@ -97,8 +97,8 @@ class CursorPagination:
|
|
| 97 |
filters.append(Query.equal('source', 'Medium'))
|
| 98 |
elif category == 'linkedin-article':
|
| 99 |
filters.append(Query.equal('source', 'LinkedIn'))
|
| 100 |
-
elif category
|
| 101 |
-
# Root
|
| 102 |
pass
|
| 103 |
else:
|
| 104 |
# Standard category filter
|
|
|
|
| 97 |
filters.append(Query.equal('source', 'Medium'))
|
| 98 |
elif category == 'linkedin-article':
|
| 99 |
filters.append(Query.equal('source', 'LinkedIn'))
|
| 100 |
+
elif category in ('research', 'data-articles'):
|
| 101 |
+
# Root categories - fetch all articles in collection (no category filter)
|
| 102 |
pass
|
| 103 |
else:
|
| 104 |
# Standard category filter
|