Skip to content

#6 - Hop Dataset Import#31

Merged
krzysztofkozyra021 merged 17 commits intomainfrom
hop-dataset-import
Mar 9, 2026
Merged

#6 - Hop Dataset Import#31
krzysztofkozyra021 merged 17 commits intomainfrom
hop-dataset-import

Conversation

@krzysztofkozyra021
Copy link
Copy Markdown
Collaborator

This should close #6

…e fields

- add alt_name, descriptors, lineage columns
- add thiols (low/medium/high)
- add agronomic: yield_min/max, maturity, wilt_disease, downy_mildew, powdery_mildew, aphid
- rename aroma_miscellaneous -> aroma_misc
- change substitutes from flat array to {brewhouse, dryhopping} JSON object
- update Hop model fillable, casts and docblock accordingly
- MapHopData: extract alt_name, descriptors, lineage, thiols, all agronomic fields
- MapHopData: store substitutes as {brewhouse, dryhopping} nested structure
- UpsertHop: add validation rules for all new fields (thiols: in:low,medium,high)
- UpsertHop: buildAttributes stores substitutes with brewhouse/dryhopping keys preserved
- ImportHopVarietyJobTest: assert aroma_misc (renamed from aroma_miscellaneous)
- ImportHopVarietyJobTest: assert substitutes as nested brewhouse/dryhopping structure
- HopFactory: add all missing fields (alt_name, descriptors, lineage, thiols, agronomic)
- HopFactory: fix substitutes to use correct nested {brewhouse, dryhopping} format
- HopFactory: use countryCode() instead of country() for realistic 2-letter codes
Storage::fake() creates real files in this directory during tests
and does not clean them up automatically after each run.
Copy link
Copy Markdown

Copilot AI left a 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 pull request implements the hop dataset import functionality requested in issue #6. It adds an Artisan command hops:import that loads hop variety data from JSON/JSON5 files stored in the local disk, processes them asynchronously via queued jobs, and stores them in the database with proper validation. The implementation includes comprehensive test coverage for both success and error scenarios.

Changes:

  • Added hops:import Artisan command to scan and dispatch import jobs for JSON/JSON5 files
  • Implemented queued job to parse, validate, and upsert individual hop varieties
  • Created actions for data mapping (JSON structure to internal format) and database upsertion
  • Extended database schema and model to support additional hop attributes (lineage, thiols, agronomic data, disease resistance)
  • Renamed Range value object to RangeOrNumber for clarity
  • Added JSON5 parser helper to support unquoted keys in data files

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
app/Console/Commands/HopsImportCommand.php New command to scan storage directory and dispatch import jobs
app/Jobs/ImportHopVarietyJob.php Queued job to process individual hop variety files with error logging
app/Actions/MapHopData.php Maps JSON structure to internal data format
app/Actions/UpsertHop.php Validates and upserts hop data with comprehensive validation rules
app/Helpers/Json5Parser.php Simple JSON5 parser to handle unquoted keys
app/Models/Hop.php Extended model with new fields and proper PHPDoc annotations
app/ValueObjects/RangeOrNumber.php Renamed from Range for better semantic clarity
database/migrations/2026_02_18_224936_create_hops_table.php Added new columns for hop attributes and renamed aroma_miscellaneous to aroma_misc
database/factories/HopFactory.php Updated factory to generate data for new fields
tests/Helpers/HopFixture.php Test fixtures providing sample JSON5 hop data
tests/Feature/Jobs/ImportHopVarietyJobTest.php Comprehensive job tests including error scenarios
tests/Feature/Console/Commands/HopsImportCommandTest.php Command tests verifying job dispatch and file filtering
tests/Feature/RangeOrNumberTest.php Updated tests for renamed class
.gitignore Added pattern to ignore test disk storage
storage/framework/testing/.gitignore Removed (replaced by root gitignore entry)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@krzysztofkozyra021 krzysztofkozyra021 merged commit 84877fc into main Mar 9, 2026
2 checks passed
@krzysztofkozyra021 krzysztofkozyra021 deleted the hop-dataset-import branch March 9, 2026 09:10
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.

Implement Hop Dataset Import Command

3 participants