Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV-562, report count of commitments by phase & org #294

Merged
merged 1 commit into from
Oct 23, 2023
Merged

DEV-562, report count of commitments by phase & org #294

merged 1 commit into from
Oct 23, 2023

Conversation

mwarin
Copy link
Contributor

@mwarin mwarin commented Oct 19, 2023

What?

Originating ticket: DEV-562

This PR is primarily adding a new report class (Reports::SharedPrintPhaseCount), that gives a count of how many commitments per organization given a phase.

So, if umich has 100 phase 3 commitments and smu has 50, and we make a phase 3 report using this new class, we expect an output file with:

organization  |phase  |commitment_count
smu           |3      |50
umich         |3      |100

(pipes and spacing added here for human readability)

Also taking this time to add a module for simplifying report output location (Utils::ReportOutput), which is starting to bug me.
If successful/useful we can (on a rainy day) start implementing in the other report scripts.

How?

If you want to run the tests:

git clone https://github.com/hathitrust/holdings-backend.git
cd holdings-backend
git fetch
git checkout DEV-562
# Start bash sesh.
bash bin/setup/setup_dev.sh
docker-compose up -d pushgateway
# Start up a shell with a profile loaded
docker-compose run --rm -e MONGOID_ENV=test dev bash

# you are now in a holdings-backend shell
# run the tests
bundle exec rspec spec/reports/shared_print_phase_count_spec.rb spec/utils/report_output_spec.rb

# run a report (which will be empty unless you load some data):
bash phctl.sh report shared-print-phase-count --inline

# When bash sesh is over: do cleanup.
docker-compose down; yes

Why?

The reporting script is simply needed.

The util script is not strictly needed, but it allows any given script that produces output files to not have to figure out where to put those files, how to name them, or know/care much about the directory structure. This also standardizes timestamps in filenames, and automatically adds a short unique-enough-ish string to avoid filename collisions.

Files changed

4 all new files:

  • lib/reports/shared_print_phase_count.rb : report script, the main payload of this PR
  • spec/reports/shared_print_phase_count_spec.rb test for report script
  • lib/utils/report_output.rb util class to potentially simplify report outputs
  • spec/utils/report_output_spec.rb test for util class

2 minimally edited files to make report script runnable from phctl.sh:

  • lib/phctl.rb
  • lib/sidekiq_jobs.rb

Reviewing/Testing

I'm mostly looking for a sanity check of the tests and the util class.

From @aelkiss I am most interested in what you think about ReportOutput as a solution for simplifying reports, since you did the trick for the temporary spec-ouputs.

@mwarin mwarin changed the title started work on report for commitment by phase & org DRAFT DEV-562, report for commitment by phase & org Oct 19, 2023
@mwarin mwarin changed the title DRAFT DEV-562, report for commitment by phase & org DRAFT DEV-562, report count of commitments by phase & org Oct 19, 2023
@coveralls
Copy link

coveralls commented Oct 19, 2023

Coverage Status

coverage: 95.012% (+0.06%) from 94.951% when pulling 198668f on DEV-562 into 7952406 on main.

@mwarin mwarin changed the title DRAFT DEV-562, report count of commitments by phase & org DEV-562, report count of commitments by phase & org Oct 19, 2023
@mwarin mwarin requested review from aelkiss and moseshll October 19, 2023 21:50
@mwarin mwarin marked this pull request as ready for review October 19, 2023 21:53
lib/utils/report_output.rb Outdated Show resolved Hide resolved
lib/utils/report_output.rb Outdated Show resolved Hide resolved
lib/phctl.rb Show resolved Hide resolved
Copy link
Member

@aelkiss aelkiss left a comment

Choose a reason for hiding this comment

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

I left a few suggestions; in particular I would like to remove the mkdir parameter from Utils::ReportOutput#dir.

@mwarin
Copy link
Contributor Author

mwarin commented Oct 23, 2023

@aelkiss I think I addressed all of your feedback. Thanks for catching the missing tests!

@mwarin mwarin merged commit cc0e52c into main Oct 23, 2023
@aelkiss aelkiss deleted the DEV-562 branch January 7, 2025 20:39
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.

3 participants