diff --git a/src/database/client.py b/src/database/client.py index d29438c..a194d63 100644 --- a/src/database/client.py +++ b/src/database/client.py @@ -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( diff --git a/src/web/templates/user/company_manage_post_types.html b/src/web/templates/user/company_manage_post_types.html index 5c14f28..3f9a441 100644 --- a/src/web/templates/user/company_manage_post_types.html +++ b/src/web/templates/user/company_manage_post_types.html @@ -187,6 +187,40 @@ function showToast(message, type = 'info') { {% endif %} + +
Dieser Post wird gespeichert und bei einer manuell gestarteten Re-Analyse mit berücksichtigt.
${escapeHtml(pt.description)}
Lade Posts...
Noch keine Posts in diesem Post-Typ.
Fehler: ${escapeHtml(error.message)}