Skip to content

Conversation

@aelkiss
Copy link
Member

@aelkiss aelkiss commented Oct 13, 2025

Adds an additional column for pages.

  • additional custom ransacker for full download
  • remove custom ransacker for pages

@aelkiss aelkiss requested a review from moseshll October 13, 2025 16:48

ransacker :pages do
Arel.sql("COALESCE(#{table_name}.pages, CASE WHEN #{table_name}.is_partial = '0' THEN 'all' ELSE 'unknown' END)")
ransacker :full_download do
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't love that the logic is kind of duplicated between the ransacker and the presenter but that may just be what we need to do right now. We may want to rethink some of this later if we end up displaying the report in Tableau or something long-term (which might let us unwind some of what we're doing in the presenter)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could consider inverting the Boolean in the database, transition is_partial to is_full or whatever. But not now.

Copy link
Member Author

@aelkiss aelkiss Oct 15, 2025

Choose a reason for hiding this comment

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

Agreed, not now. I created an issue: https://hathitrust.atlassian.net/browse/ETT-745

@coveralls
Copy link

coveralls commented Oct 13, 2025

Coverage Status

coverage: 97.636% (+0.05%) from 97.586%
when pulling ad24413 on ETT-298-two-columns
into f91fc6a on main.


def partial?
is_partial
def full_download
Copy link
Collaborator

Choose a reason for hiding this comment

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

The bang makes this a reliable Boolean, so I would rename to full_download?. However the bare is_partial will return 0 or 1 so I think we need

def full_download?
  !is_partial?
end

... to avoid Ruby's "zero is true" maldesign

Copy link
Collaborator

@moseshll moseshll Oct 14, 2025

Choose a reason for hiding this comment

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

This is confusing because I see a difference between k8s and Docker when I look at the is_partial method: bundle exec rails c on otis-testing gives 0/1 where in Docker I'm getting true/false. Our schema is doing the wrong thing, if you change db/schema.rb so is_partial looks like t.integer :is_partial, limit: 1 # TINYINT (and if necessary change the seeds to use [1,0].sample instead of bools) -- the display will always be "no" for the Full Download column (i.e., unless you swap in the full_download? method in the above comment).

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't know why the t.boolean is being ignored in k8s. But I'm pretty sure the correct thing to do is make it so we always expect an integer from is_partial and a bool from is_partial?.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will take a look at this in Kubernetes. I believe this has to do with table columns being declared as tinyint(1) vs int(1) but I'm not certain. I don't think we need is_partial? at all, and I think I ran into an issue trying to use an attribute with ? in it with the table display & ransacker stuff but I'll look again. I do agree full_download? would be preferable if possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

Verified using tinyint(1) works.

Copy link
Collaborator

@moseshll moseshll left a comment

Choose a reason for hiding this comment

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

I have a patch that should take care of the is_partial issues, I won't muddy the waters by committing the changes but I've got them at the ready if needed.

@aelkiss
Copy link
Member Author

aelkiss commented Oct 15, 2025

Regarding the requested changes:

  • Updating the schema to use tinyint(1) gets booleans in rails console

  • Regarding full_download? -- that name filters through to a lot of different places, only some of which will accept the trailing ?. I think changing the name would add some extra complexity and confusion.

Let me know if that's all OK and then I think we should be good to merge.

@aelkiss
Copy link
Member Author

aelkiss commented Oct 15, 2025

I will go ahead and rebase/resolve the conflict.

* additional custom ransacker for full download
* remove custom ransacker for pages
@aelkiss aelkiss force-pushed the ETT-298-two-columns branch from c984a8e to ad24413 Compare October 15, 2025 14:50
@aelkiss aelkiss requested a review from moseshll October 15, 2025 14:50
Copy link
Collaborator

@moseshll moseshll left a comment

Choose a reason for hiding this comment

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

This all looks good now.

@aelkiss aelkiss merged commit 3aff3a0 into main Oct 15, 2025
2 checks passed
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.

4 participants