added manual post add

This commit is contained in:
2026-04-02 10:39:07 +02:00
parent 252edcd001
commit fe15a5ab89
5 changed files with 744 additions and 7 deletions

View File

@@ -84,8 +84,6 @@ class DatabaseClient:
async def save_linkedin_posts(self, posts: List[LinkedInPost]) -> List[LinkedInPost]:
"""Save LinkedIn posts (bulk)."""
from datetime import datetime
seen = set()
unique_posts = []
for p in posts:
@@ -99,11 +97,9 @@ class DatabaseClient:
data = []
for p in unique_posts:
post_dict = p.model_dump(exclude={"id", "scraped_at"}, exclude_none=True)
if "user_id" in post_dict:
post_dict["user_id"] = str(post_dict["user_id"])
if "post_date" in post_dict and isinstance(post_dict["post_date"], datetime):
post_dict["post_date"] = post_dict["post_date"].isoformat()
# Use JSON mode so UUIDs/datetimes are serialized before the Supabase client
# builds its request payload.
post_dict = p.model_dump(mode="json", exclude={"id", "scraped_at"}, exclude_none=True)
data.append(post_dict)
if not data:
@@ -176,6 +172,15 @@ class DatabaseClient:
await cache.invalidate_linkedin_posts(user_id)
logger.info(f"Deleted LinkedIn post: {post_id}")
async def get_linkedin_post(self, post_id: UUID) -> Optional[LinkedInPost]:
"""Get a single LinkedIn post by ID."""
result = await asyncio.to_thread(
lambda: self.client.table("linkedin_posts").select("*").eq("id", str(post_id)).limit(1).execute()
)
if not result.data:
return None
return LinkedInPost(**result.data[0])
async def get_unclassified_posts(self, user_id: UUID) -> List[LinkedInPost]:
"""Get all LinkedIn posts without a post_type_id."""
result = await asyncio.to_thread(