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
customers = Retailer.find(10).customers | |
retailer_user_id = 29 | |
def to_Axlsx_excel(customers, retailer_user_id) | |
retailer_user = RetailerUser.find(retailer_user_id) if retailer_user_id.present? | |
attributes = %w[first_name last_name whatsapp_name email phone assigned_agent assigned_agent_email | |
id_type id_number address city state country created_at] | |
tags = customers.present? ? customers.first.retailer.tags.order(id: :asc) : {} | |
related_fields = customers.present? ? customers.first.retailer.customer_related_fields : {} |
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
class FileGenerationService | |
def self.generate(file_type, data, user_id) | |
# Implementa la lógica para generar el archivo | |
end | |
end | |
class S3UploaderService | |
def self.upload(file, bucket, cloudfront) | |
# Implementa la lógica para subir el archivo a S3 | |
end |
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
# Ejemplo básico de Strategy para exportar en CSV | |
class CsvExportStrategy | |
def export(customers) | |
# Implementa la lógica específica para exportar en CSV | |
end | |
end | |
# Ejemplo básico de Strategy para exportar en Excel | |
class ExcelExportStrategy | |
def export(customers) |
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
#Antes: | |
file = case type | |
when 'csv' | |
Customer.to_csv(customers) | |
when 'excel' | |
Customer.to_excel(customers, @retailer_user.id) | |
File.read(Rails.root.join('public', "export-customers-#{@retailer_user.id}.xlsx")) | |
end |
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
### Keybase proof | |
I hereby claim: | |
* I am ppeusco on github. | |
* I am ppeusco (https://keybase.io/ppeusco) on keybase. | |
* I have a public key ASBUC5yN5zMWRoG6EwqDf0Kth0qWfUDekbPI81oGagqZPAo | |
To claim this, I am signing this object: |