Commit Graph
120 Commits
Author SHA1 Message Date
Linca e23c31195b DEV: Use Rails autoloading (#321)
This commit enables Rails autoloading for Data Explorer. See:

https://meta.discourse.org/t/structuring-a-plugin-for-rails-autoloading/256092
2024-08-28 11:36:44 +08:00
锦心andDrenmi cbae98f6ed FEATURE: Allows CSV file result to be attached in automated PMs (#318)
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

Co-authored-by: Drenmi <[email protected]>
2024-08-27 11:41:12 +08:00
Loïc Guitaut c19fca4060 DEV: Update rubocop-discourse to version 3.8.0 (#292) 2024-05-28 11:16:14 +02:00
Natalie Tay b9d875cc3e FEATURE: Add ability to skip sending the PM if there are no results (#286) 2024-04-18 21:40:28 +08:00
David Battersby cde34fb316 FIX: send single report PM to groups (#284)
The main change here is that we now send a single PM to a group rather than individual PMs to each group member.

This change also adds email recipients correctly as target_emails since support was added within Discourse Automation.
2024-03-27 17:40:26 +08:00
Loïc Guitaut abe51c2aba DEV: Fix new Rubocop offenses (#282) 2024-02-29 18:15:57 +01:00
Natalie Tay 9bd70192b6 UX: Warn in /logs when PM is not sent (#271) 2023-12-11 11:08:08 +08:00
Natalie Tay ac7df5e3d0 DEV: Use plugin name appropriately in warning (#270)
Use plugin name appropriately in warning
2023-12-07 16:09:06 +08:00
Jarek Radosz e067df0b43 DEV: Update linting (#267) 2023-12-01 16:47:54 +01:00
Martin BrennanandAlexDev fbe2a37e0c Update metadata on plugin.rb (#262)
Co-authored-by: AlexDev <[email protected]>
2023-11-08 11:26:51 -08:00
David Battersby ee308c637c FIX: Scheduled PM with Data Explorer Results not sending PM (#250)
This PR fixes 2 issues that were picked up by users for the Scheduled Data Explorer Report automation script and a couple of small improvements to better match the format of manual data explorer query results.

The first issue is that within result_to_markdown the colrender contains null values, and we are currently checking length (previously treated as a packed array but it is actually a sparse array). Therefore we can check if the current index of the array is null rather than checking the size of the array.

The second issue addresses the blank query_params field. When the data explorer script does not require any params to be passed in via the automation script then it will have a nil value, however it should be defaulted to {} within the plugin.

To improve formatting the markdown table for PMs is now aligned to left and where values are substituted (for example user_id becomes username) we then include the id within brackets, for example:
user_id becomes username (user_id)
2023-07-04 14:18:56 +08:00
David Taylor 412333c25c DEV: Resolve add_to_serializer deprecations (#243)
https://github.com/discourse/discourse/commit/26b7f8a63bfdb6505b605077a4beb962a9be7b97
2023-04-24 15:45:36 +01:00
Ted Johansson bc02d030b6 DEV: Add configurable rate limit for Data Explorer API query runs (#238)
Data Explorer can run arbitrary SQL queries which can be costly for us if over-used. Because of that we want to add the ability to rate limit the query run endpoint, in particular when requested programmatically using API.

This commit introduces a rate limit to the `QueryController#run` endpoint. It heavily leans on the existing `RateLimiter` implementation, and the ability of `ApplicationController` to turn rate limit exceptions into nicely formatted JSON responses.

The rate limit (per 10 seconds) can be configured through the global setting `max_data_explorer_api_reqs_per_10_seconds`, and defaults to 2.

Handling can be configured through `max_data_explorer_api_req_mode`, and can be set to warn, block, or both warn and block. We will default to warn for now and monitor the logs for a while.
2023-04-03 13:46:35 +08:00
David Battersby 705753216c FEATURE: Allow data explorer query result to be sent as recurring PM (#233)
This feature enables admins to create reports automatically based on a recurring schedule.

It introduces a new automation script that includes the new email_group_user field added to discourse-automation, along with a query_id and query_params to pass in parameters to the existing data explorer query.

The output of the report will be sent via pm (as a markdown table) to the recipients entered within the automation script.

The automation (supports individual users, email addresses and groups).
2023-03-24 16:38:42 +08:00
Bianca Nenciu 206d937a78 DEV: Update plugin to match latest guidelines (#229)
This commit updates the plugin to the latest guidelines, as shown in
discourse-plugin-skeleton, which involves moving a lot of the code to
dedicated files, use proper namespaces, use the autoloader as much as
possible, etc.
2023-03-22 23:29:08 +02:00
Martin Brennan a684897468 DEV: Change bookmarkable registration to use new plugin API (#230)
Relies on core PR https://github.com/discourse/discourse/pull/20556
to be merged first.
2023-03-08 10:39:20 +10:00
Bianca Nenciu 0f6b30c2d8 Revert "DEV: Update plugin to match latest guidelines (#227)" (#228)
This reverts commit 9210cf6fa2.
2023-02-23 19:10:46 +02:00
Bianca Nenciu 9210cf6fa2 DEV: Update plugin to match latest guidelines (#227)
- Define extension modules
- Use different files instead of plugin.rb
- Make sure plugin is disabled according to the setting
2023-02-23 15:29:13 +02:00
David Taylor 148d6c32a3 DEV: Introduce syntax_tree for ruby formatting (#208) 2022-12-29 13:31:29 +01:00
SamandOsama Sayegh 2313237a95 FIX: better handling of edge cases (#187)
- Require query name is present
- Ensure all routes are treated by default as .json, so errors flow correctly
- Remove superflous save/cancel controls from group settings
- Remove group control when item is destroyed
- Disable editing of query when it is deleted

Co-authored-by: Osama Sayegh <[email protected]>
2022-11-18 07:09:50 +11:00
Alan Guo Xiang Tan 4236689d27 FIX: Errors when running query due to PG template patterns or comments (#189)
Before this fix, the use of PG template patterns containing ":" or the
use of "?" in comments in the SQL will result in an error being raised
because `DB.param_encoder.encode` calls ActiveRecord's `sanitize_sql_array` which is
meant for SQL fragments and not an entire SQL string.

Instead we change data-explorer to use `MiniSql::InlineParamEncoder`
instead which takes into account of template patterns and does not trip
on `?` which is a special param encoding character used by ActiveRecord.
2022-10-10 09:03:37 +08:00
Frank 45b6e7eb4f FEATURE: Bookmarkable QueryGroups. (#177)
Adds the ability for non-Admin users to bookmark Queries from inside Group > Reports > Query view.
2022-06-14 23:07:02 +08:00
Jarek Radosz 86cda5f213 DEV: Lose the es6 suffix (#165) 2022-03-05 17:21:01 +01:00
Osama Sayegh ea66bcdc75 FEATURE: Add an API scope for running queries (#154) 2022-01-21 07:15:04 +03:00
Martin Brennan 70b973ea9a FEATURE: Move query limit to hidden site setting (#153)
Previously the `QUERY_RESULT_DEFAULT_LIMIT` const was used
to limit the number of query results. This commit adds the
`data_explorer_query_result_limit` site setting which defaults
to 1000 and has a max of 10000 which matches the const
`QUERY_RESULT_MAX_LIMIT`.
2022-01-19 12:27:21 +10:00
Jarek Radosz 4626483514 DEV: Don't explicitly load files (#143)
1. It doesn't seem to be necessary?
2. It looks like it was triggering some warnings (`Creating scope :for_group. Overwriting existing method DataExplorer::Query.for_group.`)
2021-09-22 11:13:19 +02:00
Martin Brennan a61551b005 DEV: Remove bookmark reminder_type reference (#141)
See https://github.com/discourse/discourse/commit/41e19adb0d7685303009650efec3ebec0319c577
2021-09-16 10:47:42 +10:00
David Taylor 216dff3ed9 DEV: Improve logic for showing/hiding the reports tab in group screens (#107)
Previously this was adding an extra AJAX request to check if the group had any queries available. Now a boolean is included in the group serializer, so there is no need for the extra request.

Removing this ajax request will also stop other plugin JS integration tests from failing when the data-explorer plugin is installed.

This commit also fixes the HTML markup of the tab, so that it doesn't have a <ul> nested inside the existing <ul>. Also adds an icon for good measure.
2021-04-08 17:47:44 +01:00
Andrew Prigorshnev 425ba3132d FIX: bump plugin version to 0.3 (#99) 2021-03-01 16:51:48 +01:00
tshenry d18634f19a FEATURE: Include more enums (#78) 2020-10-16 17:41:39 +11:00