// posts_scheduled_publish — cron TRIGGER (every minute). Flips due `scheduled` // posts to `published`, which itself fires posts_on_publish -> notifications // (a bounded trigger-fires-trigger chain). let posts = docs::collection("posts"); let now = time::now(); let due = posts.find(#{ status: "scheduled", publish_at: #{ "$lte": now }, "$limit": 100, }); let n = 0; for r in due { let cur = r.data; cur.status = "published"; posts.update(r.id, cur); n += 1; } if n > 0 { log::info("cron published scheduled posts", #{ count: n }); }