use super::{PgPool, Uuid}; #[derive(sqlx::FromRow)] pub struct LinkPreviewRow { pub post_id: Uuid, pub url: String, pub title: Option, pub description: Option, } /// Batch-fetch link previews for a set of post IDs. #[tracing::instrument(skip_all)] pub async fn list_link_previews_for_posts( pool: &PgPool, post_ids: &[Uuid], ) -> Result, sqlx::Error> { sqlx::query_as!( LinkPreviewRow, "SELECT post_id, url, title, description FROM link_previews WHERE post_id = ANY($1) ORDER BY fetched_at", post_ids, ) .fetch_all(pool) .await }