Skip to content

AO3-3764 Paginate tag set nominations review page#5752

Merged
sarken merged 11 commits intootwcode:masterfrom
pmonfort:AO3-3764-paginate-tag-set-nominations-review
May 3, 2026
Merged

AO3-3764 Paginate tag set nominations review page#5752
sarken merged 11 commits intootwcode:masterfrom
pmonfort:AO3-3764-paginate-tag-set-nominations-review

Conversation

@pmonfort
Copy link
Copy Markdown
Contributor

Pull Request Checklist

Issue

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

Purpose

When a tag set has more than 30 unreviewed nominations, moderators currently see a random subset with the message "There are too many nominations to show at once." This makes it impossible to systematically review all nominations.

This PR replaces the random selection with proper pagination using pagy:

  • Paginate nominations by unique tagname, grouping duplicates (same tag nominated by multiple users) into a single entry
  • Each tag type (fandom, character, relationship, freeform) paginates independently with its own page param
  • Heading shows "X - Y of Z [Type]" when paginated, or "[Type] (N left to review)" when everything fits on one page
  • Pagination links include anchors to scroll to the correct fieldset
  • Order by created_at ascending for deterministic results
  • Removed the random selection logic and the "too many nominations" flash message

Testing Instructions

  1. Log in as a moderator of a tag set with more than 25 unreviewed nominations
  2. Go to Review Nominations
  3. Verify pagination links appear and each tag type paginates independently
  4. Verify that navigating pages does not affect other tag types (e.g. going to fandom page 2 keeps freeform on page 1)
  5. Verify duplicate nominations (same tagname from different users) appear only once
  6. Verify approving/rejecting tags updates counts correctly
  7. Verify tag sets with fewer than 25 nominations show no pagination links and display the "(N left to review)" heading
  8. Verify the old "There are too many nominations to show at once" message no longer appears

Credit

Pablo Monfort (he/him)

@pmonfort pmonfort force-pushed the AO3-3764-paginate-tag-set-nominations-review branch from 11f0ab0 to 0bb47cc Compare April 22, 2026 05:31
<%= check_all_none("Approve All", "Approve None", "approve") %>
<% if @paginations&.dig(tag_type) %>
<%== pagy_nav(@paginations[tag_type],
anchor_string: "id=\"#{tag_type}_nominations\"") %>
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.

Question! Does the anchor_string here mean that the pagination links should be like ?fandom_page=3#fandom_nominations?

I swear I saw that behavior when I first pulled this code to try it out, but it has disappeared on me, so I'm confused. 😆

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's the intended behavior! The anchor_string parameter name is a bit misleading, it refers to the HTML anchor element ( tag) not URL anchors/fragments. I've pushed a fix using the correct fragment parameter.
Good catch! Thanks!

Copy link
Copy Markdown
Collaborator

@sarken sarken left a comment

Choose a reason for hiding this comment

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

Just a couple of nitpicks/questions about the tests! Aside from that, this looks good and I'm excited. 🎉

Comment thread features/tag_sets/tag_set_nominations.feature Outdated
Comment thread spec/controllers/tag_set_nominations_controller_spec.rb Outdated
Comment thread spec/controllers/tag_set_nominations_controller_spec.rb Outdated
@pmonfort pmonfort force-pushed the AO3-3764-paginate-tag-set-nominations-review branch from 30a6564 to fd23efc Compare April 28, 2026 04:11
@pmonfort pmonfort requested a review from sarken April 28, 2026 04:32
Copy link
Copy Markdown
Collaborator

@sarken sarken left a comment

Choose a reason for hiding this comment

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

Just one last question!

Comment on lines +327 to +333
it "page 3 returns the remaining unique tagnames" do
get :index, params: { tag_set_id: owned_tag_set.id, fandom_page: 3 }
page3_tagnames = assigns(:nominations)[:fandom].map(&:tagname)

expect(page3_tagnames.length).to eq(noms_per_page)
expect(page3_tagnames).to eq(page3_tagnames.uniq)
end
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.

I might be missing something here. How does this tell us these are definitely the unique tagnames for page 3 and not the same tags from page 1 or 2? (It's okay if it doesn't. In my opinion, we can remove it instead of expanding it, since the test above already demonstrates the tagnames are unique. If we do that, it might also mean we can go from noms_per_page * 3 to 2.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Make sense, 2 pages is enough to validate what we need.

@pmonfort pmonfort force-pushed the AO3-3764-paginate-tag-set-nominations-review branch from 647f9b8 to 14f07c9 Compare May 1, 2026 02:03
@pmonfort pmonfort requested a review from sarken May 1, 2026 02:20
Copy link
Copy Markdown
Collaborator

@sarken sarken left a comment

Choose a reason for hiding this comment

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

🎉

@sarken sarken merged commit f077d09 into otwcode:master May 3, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants