This is a follow-up to d726c4889e5c5d7726ed1035c37d0cd60a3bb3d6.
The previous change missed changing the name of the query object when passing it to QueryResultsWrapper, which resulted in the download links not working properly after a query was run.
This change fixes that bug, and includes an acceptance test to ensure it stays fixed during future work on this plugin.
The code for listing all of the defined queries is mixed together with the code for editing a single query. Notably, this results in large amounts of unnecessary data being loaded for the list view, which causes substantial rendering slowdowns.
To address this issue, we now only load the necessary data for the list view, and load the full data when it's actually needed (any endpoint that returns a single query). The primary changes that achieve this are:
- Create a new `QueryDetailsSerializer` serialiser, which includes all of the query info, and change the existing `QuerySerializer` serialiser to only include the necessary attributes of each query for generating a list of them all.
- Split the monolith `/plugins/explorer` route into `/plugins/explorer` for showing just the list of queries, and `/plugins/explorer/queries/:query_id`, for showing/editing/running a specific query.
When reading an existing state from the params defaults or from URL params, the input elements weren't representing the right state for booleans and "3-state/null booleans".
internal /t/-/118495
When checking `attach_csv` in the `Schedule a PM with Data Explorer results`
automation script, `csv` has to be added to the list of authorized extensions in the site settings. This will now raise an error if it's not the case.
Another private plugin is extending this plugin and the current_user check here is a problem -- adding safe navigation does not break any existing functionality but allows for future changes.
Followup da1c99ec2d272a4eac8586a8b61794e8b755619b
We already had the functionality to convert results like
this:
```
|blah_url|
|--------|
|3,https://test.com|
```
To a link clientside, so in the UI it looks like this:
```
<a href="https://test.com">3</a>
```
With the addition of the recurring report to post automation,
and the existing report to PM automation, we also need to be
able to do this server-side, so reports don't come out malformed
if they have these type of count + URL columns.
The primary key is usually a bigint column, but the foreign key columns
are usually of integer type. This can lead to issues when joining these
columns due to mismatched types and different value ranges.
This script is similar to the existing one that schedules
report results to to be sent to a PM on a regular basis,
but instead takes a topic ID and posts to that. This way
people can have report results sent to a public topic regularly
too and not have to deal with PM recipients and so on.
* UX: Automatically convert to lowercase in explorer-schema
In the past, ExplorerSchema searches were case-sensitive, so if the
user's input method capitalized the first letter, it was likely that no
results would be found.
The new change allows you to enter uppercase letters, which will
automatically be converted to lowercase when searching.
meta topic: https://meta.discourse.org/t/can-the-data-explorer-search-input-be-converted-to-lower-case/323435
This commit uses GroupChooser as the input for param input of type
group_id. Meanwhile, it improves invalid group validation and semantic
error prompts.
This commit refactors the category id normalization of param-input to
use `Category.asyncFindBySlugPath`.
Now, the category id input will use an async query when the
default/initial value is category slug.
Co-authored-by: Natalie <1555215+nattsw@users.noreply.github.com>
The old float validation had several bugs. It will recognize strings
like "a1.2" and "3.4b" as valid doubles, but will not recognize integers
like "1234" as doubles. Also, since an empty string is not falsy in Ruby,
it will recognize "Inf" as -Infinity.
This commit fixes these issues
Validation of `user_id` parameter will throw a 500 error because
`User.find_by_username_or_email` does not throw
`ActiveRecord::RecordNotFound`, but silently returns `nil`.
This results in a `NoMethodError` in `object.id` on the next line
What's the problem?
===================
TL;DR: When the user enters an incorrect default value, its
corresponding param-input will disappear
When creating a parameter from SQL, we perform cast_to_ruby, which means
that if the default value given by the user is invalid, the entire
parameter will not be added to the param_list of the query.
This behavior is very confusing, and users will not understand why an
incorrect initial value will cause the param-input to disappear.
What's the fix?
================
The cast_to_ruby process is canceled in create_from_sql, so that
param-input with incorrect default value will still be displayed.
We have a simple validation process on the front end, which is enough to
prompt whether some default inputs are incorrect.