Pseudocode
1function scheduleNextPost(posts, channel):
2 filter posts where status = "queued"
3 for each platform in channel.platforms:
4 pick earliest matching post
5 if rate-limited, defer 15 min
6 send to platform queue
7 log dispatch + update status
8 return dispatched count
2 filter posts where status = "queued"
3 for each platform in channel.platforms:
4 pick earliest matching post
5 if rate-limited, defer 15 min
6 send to platform queue
7 log dispatch + update status
8 return dispatched count
TypeScript — auto-typed, tested
1export async function scheduleNextPost(
2 posts: Post[],
3 channel: Channel
4): Promise<DispatchResult> {
5 const queued = posts.filter(p => p.status === 'queued');
6 let dispatched = 0;
7 for (const platform of channel.platforms) {
8 const next = pickEarliestFor(queued, platform);
9 if (await isRateLimited(platform)) {
10 await defer(next, '15m'); continue;
11 }
12 await dispatch(next, platform);
13 dispatched++;
14 }
15 return { dispatched, channelId: channel.id };
16}
2 posts: Post[],
3 channel: Channel
4): Promise<DispatchResult> {
5 const queued = posts.filter(p => p.status === 'queued');
6 let dispatched = 0;
7 for (const platform of channel.platforms) {
8 const next = pickEarliestFor(queued, platform);
9 if (await isRateLimited(platform)) {
10 await defer(next, '15m'); continue;
11 }
12 await dispatch(next, platform);
13 dispatched++;
14 }
15 return { dispatched, channelId: channel.id };
16}
RAG SUGGESTION · matched 4 prior translations
In your codebase, "send to platform queue" maps to await dispatch(item, platform)
Vertex AI · Anthropic · Voyage
Cycle 14,892 · 1.4s · type-checked ✓ · tests ✓
CONFIDENCE
97%