-
Notifications
You must be signed in to change notification settings - Fork 123
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
Csv background job #1281
Csv background job #1281
Conversation
app/controllers/organizations/staff/external_form_upload_controller.rb
Outdated
Show resolved
Hide resolved
Turbo::StreamsChannel.broadcast_replace_to @file.signed_id, | ||
target: "results", | ||
partial: "organizations/staff/external_form_upload/upload_results", | ||
locals: { | ||
import: Status.new(@errors.empty?, @count, @no_match, @errors) | ||
} |
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.
Broadcast the import status when the import is complete.
@@ -1,21 +1,21 @@ | |||
<turbo-frame id="results"> |
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.
This was not actually doing anything with a turbo frame so a div is more appropriate.
</small> | ||
</div> | ||
<div class="ps-2"> | ||
<%= form.submit t("general.attach"), class: "btn btn-outline-success" %> | ||
</div> | ||
</div> | ||
<% end %> | ||
<%= turbo_frame_tag "results" %> |
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.
Moved to the external form index. This partial is used in multiple locations and the results are really only need for the csv import.
get current org in service
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.
Nice! @jmilljr24 Very cool. Just one comment re tenant. It would be good to get this into production and test it, soon. I will be adding baja to prod later on today (they won't be uploading form data any time soon as there's not much point without adopters signing up so no major rush).
@kasugaijin I'll start working on fixing the tests! Thanks for taking a look. |
I'm open to suggestions on testing. I decided to remove some things from the controller test as it seemed beyond the scope of the controller and overly complicated things. The csv service has good test coverage so I don't think we need to duplicate that in the controller test. I didn't add any tests for the job simply because there really is no additional logic in the job other than calling the service. |
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.
Nice work @jmilljr24
🔗 Issue
✍️ Description
This adds a background job to process the csv import. Some changes had to be made to the import service but where minor enough where the service could be run independent of the background job if needed.
This uses Active Job for the background job and uses
Turbo::StreamsChannel
to broadcast the update when the job is completed.Tests updated.
📷 Screenshots/Demos
Screencast.from.2024-12-19.07-19-35.webm