-- name: GetAnalyticsPostsInRange :many SELECT post_id, post_text, post_timestamp, likes, reposts, replies, quotes FROM analytics_posts WHERE user_id = $1 AND platform = $2 AND post_timestamp >= $3 AND post_timestamp <= $4 ORDER BY post_timestamp DESC LIMIT $5; -- name: UpsertAnalyticsPosts :exec INSERT INTO analytics_posts (user_id, platform, post_id, post_text, post_timestamp, likes, reposts, replies, quotes) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) ON CONFLICT (user_id, platform, post_id) DO UPDATE SET post_text = EXCLUDED.post_text, post_timestamp = EXCLUDED.post_timestamp, likes = EXCLUDED.likes, reposts = EXCLUDED.reposts, replies = EXCLUDED.replies, quotes = EXCLUDED.quotes;