Skip to content
This repository was archived by the owner on Jul 14, 2025. It is now read-only.

FEATURE: Allows CSV file result to be attached in automated PMs#318

Merged
Lhcfl merged 4 commits intomainfrom
add-attachable-csv
Aug 27, 2024
Merged

FEATURE: Allows CSV file result to be attached in automated PMs#318
Lhcfl merged 4 commits intomainfrom
add-attachable-csv

Conversation

@Lhcfl
Copy link
Copy Markdown
Contributor

@Lhcfl Lhcfl commented Aug 26, 2024

This commit adds an optional setting that allows to attach query results in CSV format as a file to PMs sent by Data Explorer's automation scripts.

meta topic: https://meta.discourse.org/t/turn-data-explorer-query-results-into-csv-to-attach-to-discourse-automated-emails/267529

Screenshots

image
image

Lhcfl added 2 commits August 26, 2024 11:42
This commit adds an optional setting that allows to attach query results
in CSV format as a file to PMs sent by Data Explorer's automation
scripts.

meta topic: https://meta.discourse.org/t/turn-data-explorer-query-results-into-csv-to-attach-to-discourse-automated-emails/267529
Copy link
Copy Markdown
Contributor

@Drenmi Drenmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

A few opportunities for improving the existing data model, but only suggestions, nothing that blocks this PR. 👍

params = params_to_hash(query_params)

result = DataExplorer.run_query(query, params)[:pg_result]
result = DataExplorer.run_query(query, params)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking if we can promote the return value from a hash to a class or struct instead. Then we could implement for example result.empty? and use that on L:15. It could also implement result.convert which could be delegated to the new converter class. WDYT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe? But I'm not sure. This result structure should be used in many places. Changing it will affect many files.


it "works with attached csv file" do
SiteSetting.personal_message_enabled_groups = group.id
DiscourseDataExplorer::ResultToMarkdown.expects(:convert).returns("le table")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-08-27 at 10 49 31 AM

@Lhcfl Lhcfl force-pushed the add-attachable-csv branch from d37dddf to 73467e5 Compare August 27, 2024 03:15
Co-authored-by: Drenmi <drenmi@gmail.com>
@Lhcfl Lhcfl force-pushed the add-attachable-csv branch from 73467e5 to e998739 Compare August 27, 2024 03:17
@Lhcfl
Copy link
Copy Markdown
Contributor Author

Lhcfl commented Aug 27, 2024

Thank you for your review! 🚀

@Lhcfl Lhcfl merged commit cbae98f into main Aug 27, 2024
@Lhcfl Lhcfl deleted the add-attachable-csv branch August 27, 2024 03:41
KrisKotlarek added a commit that referenced this pull request Apr 23, 2025
Bug introduced during refactoring in this PR: #318

Explain parameter must be passed to `ResultFormatConverter`.
KrisKotlarek added a commit that referenced this pull request Apr 23, 2025
Bug introduced during refactoring in this PR: #318

Explain parameter must be passed to `ResultFormatConverter`.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants