Last active
September 5, 2022 19:54
-
-
Save michalkorzawski/352f98ec0d0248082ddd6cb60a080bcd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # app/services/importers/users.rb | |
| module Importers | |
| class Users | |
| include CableReady::Broadcaster | |
| def initialize(file:) | |
| @file = file | |
| end | |
| def import_csv | |
| counter = 0 | |
| total = CSV.read(@file.path, headers: true).length | |
| CSV.foreach(@file.path, headers: true) do |csv_row| | |
| counter += 1 | |
| ... | |
| cable_ready[UserChannel].text_content( | |
| selector: '#processed-row-number-container', | |
| text: counter | |
| ).broadcast_to(Current.user) | |
| # more about Current.user -> https://api.rubyonrails.org/classes/ActiveSupport/CurrentAttributes.html | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment