-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
feat: Contact Exports #7258
feat: Contact Exports #7258
Conversation
✅ Deploy Preview for chatwoot-storybook canceled.
|
.gitignore
Outdated
@@ -31,6 +31,7 @@ master.key | |||
.env | |||
|
|||
public/uploads | |||
public/contacts |
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.
@sojan-official Need your thoughts on where we should save the file for contacts export.
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.
wouldn't need this folder / the file doesn't need to be stores in an open folder.
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 need to change the way the export files are stored.
ref comments.
|
||
def send_an_email_to_team(account) | ||
subject = "Your contact's export file is available to download." | ||
@action_url = "#{Rails.root}/public/contacts/#{account.name}_#{account.id}_contacts.csv" |
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.
@tejaswinichile This wouldn't work well on production as we use multiple nodes to serve the requests. Also, this creates the file in the sidekiq pod and won't be available for the rails server.
So the flow should be that we create a temp file in the job, create an active record object uploading that file to the filestore, ie ( AWS, GCS etc ) .. and use that URL in the email.
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.
@sojan-official Should we attach file this to the account or contact if we are creating an active storage object, or just an individual object, is fine?
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.
@tejaswinichile it will be a nice idea to attach to account, as we can delete these objects on account destroy
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.
@sojan-official Attaching it to the account.
When I select lable it doesn't show the contacts assigned with that label because the label is on conversation not on contact |
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.
Mostly there. few comments
.gitignore
Outdated
@@ -31,6 +31,7 @@ master.key | |||
.env | |||
|
|||
public/uploads | |||
public/contacts |
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.
wouldn't need this folder / the file doesn't need to be stores in an open folder.
|
||
path_to_file = "#{Rails.root}/public/contacts/#{account.id}/#{account.name}_#{account.id}_contacts.csv" | ||
|
||
expect(CSV.open(path_to_file, 'r')).to be_truthy | ||
File.delete(path_to_file) |
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 doesn't look right ? 😅
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.
lets also just verify the csv file contains the legit data
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.
lets also just verify the csv file contains the legit data
Open and read downloaded file.
This doesn't look right ? 😅
It was persistent in the machine after the test are done running :D
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.
Addressed this.
@sojan-official I Tested the export on staging, please have a look. https://www.loom.com/share/ea556d2a054f40db9f9cb3ffcbe4dce5 |
def attach_export_file(account, csv_data) | ||
return if csv_data.blank? | ||
|
||
account.contacts_export.attach( |
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.
What happens in cases where the account already has a contact_export attached?
Will calling .attach again purge the file from our storage? or should we do it explicitly?
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.
It replaces the same file @sojan-official and purges the old one automatically.
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.
- PTAL the added comment
- LGTM otherwise
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Fixes: https://linear.app/chatwoot/issue/CW-1795/export-of-contacts
https://www.loom.com/share/8e429675bd8645fe9ba53d5b57d14e3a