-
Notifications
You must be signed in to change notification settings - Fork 25
🎁 Creates a sample CSV importing template file #1077
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
Conversation
dd6591a to
4713fa6
Compare
This file can be used as a template for creating imports.
6412b8e to
6084196
Compare
218adfe to
629610f
Compare
Call in controller is temporary, so pull out the code it uses since it will be removed later. Complete logic in csv service.
Rake task doesn't work any more.
75e67b8 to
8332b79
Compare
WIP - not all have specs yet
Simple form bootstrap configuration was overriding the stylies.
5513b32 to
df68a31
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a new SampleCsvService that generates tenant-specific CSV import templates for Bulkrax. The service creates sample CSV files with appropriate headers, field descriptions, and example values based on the repository's work types and field mappings, supporting both ActiveFedora and Valkyrie models.
Changes:
- Adds a modular
SampleCsvServicewith 12 supporting classes that analyze schemas, build columns/rows, and generate CSV templates - Implements a "Generate CSV Import Template" button in the importer creation UI with corresponding controller action and route
- Removes the deprecated
generate_test_csvsrake task that created fake test data
Reviewed changes
Copilot reviewed 30 out of 31 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| app/services/bulkrax/sample_csv_service.rb | Main orchestrator service that coordinates CSV generation through specialized components |
| app/services/bulkrax/sample_csv_service/*.rb | Supporting classes for model loading, field analysis, column/row building, and CSV output |
| app/controllers/bulkrax/importers_controller.rb | Adds sample_csv_file action to generate and download CSV template |
| app/views/bulkrax/importers/new.html.erb | Adds "Generate CSV Import Template" button and updates submit button styling |
| app/views/bulkrax/exporters/new.html.erb | Updates submit button styling for consistency |
| config/routes.rb | Adds POST route for sample_csv_file action |
| config/locales/bulkrax.en.yml | Adds translation for "Generate Sample CSV" action |
| lib/tasks/bulkrax_tasks.rake | Removes deprecated generate_test_csvs rake task |
| spec/services/bulkrax/sample_csv_service/*.rb | Test coverage for service classes (some files are empty stubs) |
| app/assets/stylesheets/bulkrax/import_export.scss | Minor whitespace cleanup |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
spec/services/bulkrax/sample_csv_service/explanation_builder_spec.rb
Outdated
Show resolved
Hide resolved
| @@ -14,108 +14,6 @@ namespace :bulkrax do | |||
| end | |||
| end | |||
|
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooo I didn't know we had a rake task for this. Is it no longer valid? 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know either! It was set up to create test data of some sort I believe, but it was very out of date and did not work when I tried it. I decided it was probably best to remove it - keeping it felt misleading. I could be persuaded otherwise if there's any valid reason to keep it around.
ShanaLMoore
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate all the specs added to Bulkrax! 👏🏿
There is some longstanding code in lib/bulkrax.rb that Rubocop began complaining about. This commit addresses those offenses.
The sample CSV generation only works if Hyrax is defined in the application, so the button should only appear if Hyrax is defined as well.
Summary
Creates a service which generates a sample CSV file to be used as a template for creating imports. This is Hyku tenant-specific because Hyku stores the Bulkrax field mappings at a tenant level, and should work for current Hyku with both flexible metadata
falseandtrueSample File & Caveats
Sample CSV created by service
bulkrax_template_20260127_015533.csv
Note
Using the schema's form definition to determine which terms to include may allow us to remove the ignore list. However while we are attempting to support (with no guarantee that it will work) ActiveFedora's defined models, this wouldn't work, so the ignored properties in CsvBuilder class remain for now.