[TAN-7137] Add scheduled publication status transitions#13608
Open
[TAN-7137] Add scheduled publication status transitions#13608
Conversation
927443e to
1bbbf45
Compare
Collaborator
|
1bbbf45 to
fd8ecda
Compare
…cation Add columns, validations, and effective status computation for scheduling future publication status transitions. Scopes and predicates reflect the effective status immediately when the scheduled time passes.
…d folder policies
Background job that materializes scheduled publication status transitions.
When a schedule is set via project or folder update, the `SideFx` service enqueues `ProcessScheduledPublicationTransitionJob` with `wait_until: scheduled_at`.
…ct publication_status column references Many places queried admin_publications.publication_status directly in SQL joins and where clauses. These bypass the effective status computation and wouldn't account for scheduled transitions whose time has passed.
… definitions
Store the scheduling user in a new `scheduled_by_id` column on admin_publications instead of passing it as a job argument. This lets us materialize the status transition from other places too, such as a sweep job that recovers failed scheduled transitions, or a controller that needs to handle edge cases when the publication status is changed after `scheduled_at` has passed but before the materialization job has run.
When an admin modifies or deletes a project after scheduled_at has passed but before the job ran, the SideFx service now runs the transition synchronously first. This ensures side effects like activity logs, emails, and first_published_at are recorded before the admin's operation proceeds.
…jects Projects that were scheduled to publish and whose publish date has already passed are now protected from moderator deletion, even if the materialization job hasn't run yet.
…llers The ProcessScheduledPublicationTransitionsJob (plural) now sweeps through all due transitions by default, but you can also target a specific one by passing an admin_publication. Moved synchronous materialization out of SideFx services and into controllers, right before assign_attributes. This sidesteps conflicts from unpersisted changes and avoids infinite recursion. Also added the job to hourly_jobs.rake as a safety net.
fd8ecda to
4c6cbbe
Compare
Only expose `scheduled_status` and `scheduled_at` attributes to moderators and admins.
f63bd3a to
388cdeb
Compare
# Conflicts: # back/app/services/side_fx_project_service.rb # back/db/structure.sql
Moving the logic that auto-sets `scheduled_by` since it felt a bit hidden in the side fx service, plus refactoring parameter extraction in the controllers.
When filter_by is not provided, nil.in? returns false, so no scope is built. The ordering method then crashes with PG::UndefinedColumn because it references a column from a JOIN that was never applied.
…ation: subquery) where(association: scope) generates self-contained subqueries that don't modify the outer query's structure — no extra joins or tables in the FROM clause that could interfere with selects, ordering, or other conditions. joins.merge alters the query structure and risks scope leaking or merge conflicts.
…eate` We could reconsider allowing these fields at some point. For now, it's not necessary since we always schedule existing projects, not new ones. Also, with the current implementation, if you provide a publication status along with scheduling attributes, the latter will simply be ignored. This isn't a case we're looking to fix or support at this stage. For folders, the same list of attributes is actually permitted for both creation and updates, but that's mostly out of convenience since the policy doesn't have separate `permitted_attributes_for_create` and `permitted_attributes_for_update` methods.
…rison Phase `end_at` is exclusive (the phase is no longer active at that moment), so a project is finished when `last_phase_end_at <= now`.
68211de to
14a2fbb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog
For translators
TODOs
ProcessScheduledPublicationTransitionsJob