Skip to content

AO3-7457 Extract work blurb presenter#5911

Open
nateberkopec wants to merge 2 commits into
otwcode:masterfrom
nateberkopec:nb/work-blurb-presenter
Open

AO3-7457 Extract work blurb presenter#5911
nateberkopec wants to merge 2 commits into
otwcode:masterfrom
nateberkopec:nb/work-blurb-presenter

Conversation

@nateberkopec

@nateberkopec nateberkopec commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Pull Request Checklist

Issue

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

Purpose

My end goal is to cache work blurbs, and to fetch them all in a single MGET for all relevant work blurbs.

In order to do this, we need a single place where we can make all the following decisions:

  1. For each work, will we display the mystery or the full module?
  2. Are we going to include the blurb "chrome" or not?
  3. How many works are there?

The end goal is something that will look like:

render: WorkBlurbPresenter.new(@works), cached: true

... and that will Just Work, resulting in a single MGET cache call.

We can't do this without this presenter, primarily because of the mystery/non-mystery module distinction, which needs to be calculated on a per-work basis.

I also think this cleans up the code quite nicely:

  1. The special case re: an admin viewing a users Works in Collections page is now taken care of on that page rather than in the partial.
  2. A number of places where we weren't using collection: options got cleaned up
  3. The logic on when a mystery blurb is appropriate is extracted to the presenter and much easier to read
  4. A lot of that logic can now be tested in spec/presenters/work_blurb_presenter_spec.rb.

References

@nateberkopec nateberkopec changed the title Extract work blurb presenter AO3-7457 Extract work blurb presenter Jun 25, 2026
@nateberkopec nateberkopec force-pushed the nb/work-blurb-presenter branch from 67154f8 to 6541bd0 Compare June 25, 2026 23:26
<% id = "blurb_#{collection_item.item_type}_#{collection_item.item_id}_#{collection_item.collection.name}" %>
<blockquote id="<%= id %>" class="<% if collection_item.item_type == 'Bookmark' %>bookmark <% else %>work <% end %> blurb toggled">
<% if collection_item.item_type == 'Work' %>
<%= render "works/work_module", work: collection_item.item, is_unrevealed: false %>

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.

Note: this is_unrevealed thing was a no-op.

@nateberkopec

Copy link
Copy Markdown
Contributor Author

Noticed a missing i18n, fixed.

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.

1 participant