-
Notifications
You must be signed in to change notification settings - Fork 74
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
Enqueue CSVs from the CLI #322
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
We could also support --csv -
for stdin, and also just loading from the stdin if it's not a TTY when using pipes like curl https://example.com/posts.csv | bundle exec maintenance_tasks perform Maintenance::ImportPostsTask
but than can be done in another PR.
adrianna-chang-shopify
force-pushed
the
csv-from-cli
branch
from
February 9, 2021 21:39
81b47bd
to
f59a4f5
Compare
adrianna-chang-shopify
force-pushed
the
csv-from-cli
branch
from
February 11, 2021 19:55
65d8354
to
18f8999
Compare
etiennebarrie
approved these changes
Feb 11, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This should be the last missing piece for CSV functionality in the gem. This PR allows a file to be passed via a
--csv
option on the CLI in order to run CSV processing Tasks from the command line.Changes
--csv
option to the CLI. If a file is supplied, we build an attachable (see https://edgeguides.rubyonrails.org/active_storage_overview.html#attaching-file-io-objects) to send toRunner.run
. The CLI will surface the error if the file doesn't exist / isn't openable / etc.Runner.run
to verify that the Task processes CSVs before attaching the CSV (since a user can now pass a CSV for a non-CSV Task via the CLI).Task.named
from the CLI to check if the Task includes theCsvCollection
module, and I felt like the CLI should not be aware of such constants and the details of howTask
andCsvCollection
are relatedcsv_file
supplied, we raise.Runner.run
to run a CSV Task (which is possible today, but not documented)Tophatting
The following scenarios are relevant to 🎩
In
test/dummy
:be maintenance_tasks perform 'Maintenance::ImportPostsTask'
=>error Maintenance::ImportPostsTask must be supplied with a CSV file to process.
Cannot parse nil as CSV
will be surfaced in the UIbe maintenance_tasks perform 'Maintenance::ImportPostsTask' --csv 'invalid.csv'
=>error No such file or directory @ rb_sysopen - invalid.csv
be maintenance_tasks perform 'Maintenance::ImportPostsTask' --csv '../fixtures/files/sample.csv'
be maintenance_tasks perform 'Maintenance::UpdatePostsTask'
--csv '../fixtures/files/sample.csv'`