Update scheduled post retrieval to include associated post and page data

Modify `getScheduledPosts` in `DatabaseStorage` to left join `socialPages` and return an array of objects containing `scheduled_posts`, `posts`, and `social_pages` data.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/TXBOLMj
This commit is contained in:
michaelschal committed 2025-10-08 14:07:31 +00:00
1 parent 23f91266e2
commit 9f8b6fce12
2 files changed
+12 -3

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

+12 -3
View File
@@ -185,11 +185,12 @@ export class DatabaseStorage implements IStorage {
}
// Scheduled Posts
async getScheduledPosts(userId: string, startDate?: Date, endDate?: Date): Promise<ScheduledPost[]> {
async getScheduledPosts(userId: string, startDate?: Date, endDate?: Date): Promise<any[]> {
let query = db
.select()
.from(scheduledPosts)
.innerJoin(posts, eq(scheduledPosts.postId, posts.id))
.leftJoin(socialPages, eq(scheduledPosts.pageId, socialPages.id))
.where(eq(posts.userId, userId));
if (startDate && endDate) {
@@ -199,11 +200,19 @@ export class DatabaseStorage implements IStorage {
const scheduledAt = new Date(r.scheduled_posts.scheduledAt);
return scheduledAt >= startDate && scheduledAt <= endDate;
})
.map(r => r.scheduled_posts);
.map(r => ({
...r.scheduled_posts,
post: r.posts,
page: r.social_pages,
}));
}
const results = await query;
return results.map(r => r.scheduled_posts);
return results.map(r => ({
...r.scheduled_posts,
post: r.posts,
page: r.social_pages,
}));
}
async getScheduledPost(id: string): Promise<ScheduledPost | undefined> {