Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 10, 2026

Adds ability to schedule drafts for automatic publishing at a future date/time via hourly background job.

Backend

  • GP Draft doctype: Added scheduled_at DateTime field
  • Scheduler: New publish_scheduled_drafts() runs hourly, queries drafts where scheduled_at <= now() and calls existing publish() method
  • Error handling: Individual failures logged without blocking other drafts
def publish_scheduled_drafts():
    scheduled_drafts = frappe.db.get_all(
        "GP Draft",
        filters=[
            ["scheduled_at", "<=", now()],
            ["scheduled_at", "is", "set"],
        ],
        fields=["name", "owner"],
    )
    for draft_info in scheduled_drafts:
        try:
            draft = frappe.get_doc("GP Draft", draft_info.name)
            if draft.type == "Discussion":
                draft.publish()
        except Exception as e:
            frappe.log_error(...)

Frontend

  • NewDiscussion UI: DatePicker with clock icon in header, format: "15 Feb, 2026 at 3:30 PM"
  • State management: Extended draftData localStorage to include scheduled_at, integrated with auto-save flow
  • Type safety: Updated GPDraft TypeScript interface

Users set schedule via DatePicker → draft auto-saves with scheduled_at → hourly job publishes when time arrives.

Original prompt

In the NewDiscussion page, add the option to schedule a draft to be published. Implement this as follows:

  1. Add a new field named scheduled_at to the GP Draft Doctype. This should be a DateTime field.
  2. Modify the UI of the NewDiscussion page to include an option for the user to schedule the draft. If the user sets a schedule, store the corresponding date and time in the scheduled_at field of the GP Draft Doctype.
  3. Create a new hourly job named publish_scheduled_drafts in the gp_draft.py file. This job should:
    • Periodically check for drafts with the scheduled_at field set to a time less than or equal to the current time.
    • Publish these drafts and update their status accordingly.
  4. Ensure publish_scheduled_drafts is registered in the hooks.py file to execute on an hourly basis.

This enhancement will add functionality to schedule drafts for automatic publishing, increasing usability and efficiency for users.

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add option to schedule drafts for publication Add scheduled publishing for discussion drafts Feb 10, 2026
Copilot AI requested a review from netchampfaris February 10, 2026 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants