Skip to content

AO3-7135 Record canonized/decanonized dates on tags - #5954

Open
pmonfort wants to merge 1 commit into
otwcode:masterfrom
pmonfort:AO3-7135
Open

AO3-7135 Record canonized/decanonized dates on tags#5954
pmonfort wants to merge 1 commit into
otwcode:masterfrom
pmonfort:AO3-7135

Conversation

@pmonfort

Copy link
Copy Markdown
Contributor

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-7135

Purpose

Adds two new datetime columns (canonized_at and decanonized_at) to the tags table to record when a tag was most recently canonized or decanonized.

  • A before_save callback sets canonized_at when a tag becomes canonical, and decanonized_at when it becomes non-canonical.
  • The tag edit page displays "Last canonized on [datetime] UTC" and "Last decanonized on [datetime] UTC" to admins (superadmin, policy_and_abuse, tag_wrangling), directly below the "last edited" information. Sentences are omitted when the corresponding date is nil.
  • Both fields are indexed in Elasticsearch and exposed as sort options ("Date Canonized", "Date Decanonized") in tag search.

Testing Instructions

  1. Log in as a tag wrangler.
  2. Create a new tag (non-canonical). Edit it, you should not see "Last canonized on" or "Last decanonized on".
  3. Create a new canonical tag. Edit it, you should not see the dates (wranglers don't see them).
  4. Log out.
  5. Log in as an admin with superadmin, policy_and_abuse, or tag_wrangling role.
  6. Edit the non-canonical tag from step 2, you should not see any canonization dates.
  7. Check "Canonical", save, and re-edit, you should see "Last canonized on [datetime] UTC"
  8. Uncheck "Canonical", save, and re-edit, you should see both "Last canonized on" and "Las
  9. Edit the canonical tag from step 3, you should see "Last canonized on [datetime] UTC" on
  10. Find a tag that was canonized before this deployment and decanonize it, it should shotetime] UTC" only (no canonized date since that happened before the migration).
  11. Log out.
  12. Search > Tags, verify "Date Canonized" and "Date Decanonized" appear in the "Sort by" d
  13. Sort by "Date Canonized" descending, recently canonized tags should appear first.
  14. Sort by "Date Decanonized" descending, recently decanonized tags should appear first.

Credit

Pablo Monfort (he/him)

@github-actions github-actions Bot added Has Migrations Contains migrations and therefore needs special attention when deploying Awaiting Review labels Jul 29, 2026
@pmonfort
pmonfort force-pushed the AO3-7135 branch 2 times, most recently from ed85026 to b2c6cf2 Compare July 29, 2026 05:10

@sarken sarken left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking pretty good! Could you add a test in features/tags_and_wrangling/tag_search.feature to check the results of sorting?

And I should not see "Last decanonized on"
When I check "Canonical"
And I press "Save changes"
And I edit the tag "Amelie"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once you save changes, you should be redirected to the tag edit page, so this step would ideally be unnecessary... Did you try it without? (I can understand if you did and it failed due to the test running too quickly, but I wanted to ask just the same.)

<% if @tag.canonized_at || @tag.decanonized_at %>
<p class="notes">
<% if @tag.canonized_at %>
<%= t(".last_canonized", date: @tag.canonized_at.utc.strftime("%Y-%m-%d %H:%M:%S")) %>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need strftime here? I get the desired format just by using utc (although, to be fair, I tried it on @tag.updated_at since that was what I had handy)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Has Migrations Contains migrations and therefore needs special attention when deploying Reviewed: Action Needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants