Commit Graph

90 Commits

Author SHA1 Message Date
Kane York 386635d693
FIX: UserAction table did not have enum help (#62)
Requires 2.6.0.beta3
2020-10-07 12:58:14 +11:00
Krzysztof Kotlarek fe0806eb2a
FEATURE: introduce data-explorer tables (#61)
Instead of using `PluginStoreRow` we should use plugin-specific models like `DataExplorer::Query` and `DataExplorer::QueryGroup`
2020-08-27 10:29:57 +10:00
Mark VanLandingham 5bf875a1ac
FIX: Do not show hidden queries in group reports (#57) 2020-08-10 15:12:06 -05:00
Ricky Chon dcfb92d7f8
FEATURE: Add ability to soft delete (hide) queries and revert deletion with rake tasks (#54)
* FEATURE: Add hide button (toggleable) for all queries (frontend only)

* Switches between hide/unhide on click
* Works almost like the delete button, but toggles between the query's
hidden attribute instead
* So far this is only a frontend feature, the backend implementation
still needs work

* Revert "FEATURE: Add hide button (toggleable) for all queries (frontend only)"

This reverts commit a8771d2ad5.

REVERT: Remove button that hides queries (frontend)

* Prepare for migration of old frontend logic to backend
* We are going to reuse the existing delete button, but change its
backend logic to enable soft deletion. From the user's perspective
nothing will change, but any deletion mistakes can be reverted.

* DEV: Hide user queries upon deletion, but keep them in store

* Creating a new query will set its hidden attribute to false by
default
* Deleting a user-made query will not delete it from the store, but
set its hidden attribute to true
* User queries will not be indexed if they are hidden
* Undeleting a query will unhide it, and will be indexed
* Updating a hidden query will unhide it, and will be indexed

* SPEC: Add spec for hidden/deleted queries

* Hidden queries should not be shown

* FEATURE: Add ability to delete/hide system queries

* System queries are now able to be deleted from view, but will remain
in the backend for retrieval, if necessary

* FEATURE/DEV: Add rake commands for query soft deletion

* query:list_hidden - Shows a list of hidden queries
* query:hide_all[only_default] - Hides all queries, w/ boolean arg to
hide only default ones
* query:unhide[id] - Unhides a query by id
* query:unhide_all[exclude_default] - Unhides all hidden queries,
w/ boolean arg to exclude default ones

* Remove rails loggers

* UX/DEV: Update query rake tasks to be more user friendly

* Split query:hide_all[only_default] into two tasks:
    * query:hide_all - Hides all queries
    * query:hide_all:only_default - Hide only default queries
* Split query:unhide_all[exclude_default] into two tasks:
    * query:unhide_all - Unhides all hidden queries
    * query:unhide_all:exclude_default - Unhides all non-default
    queries
* Rename file to match task name

* UX: query:unhide can accept multiple arguments

* Example: rake query:unhide[-5,-6,-7,3,5,6,-13,-14,-10]

* UX: Update query rake tasks to output cleaner messages

* Remove unneeded comment

* DEV: Keep only necessary rake tasks, use more specific naming

* UX/DEV: Add rake task for hard deletion, better console logs

* User is able to hard delete a query only if it is hidden, otherwise
output a message stating so
* Add commented examples above each task
* Add rainbow support for more readable console logs
* Successful messages will display green, failures display red,
additional info displays yellow
* Separate multiple queries with spaces instead of lines

* DEV: Remove rainbow colorizing in console logs

* Rainbow is a dependency of rubocop and it may go away in the future
* Rainbow is only used for dev and test environments

* DEV: Add Rails engine to enable rake tasks to be loaded at runtime

* DEV: Favor require - load files only if they are not already loaded

* SPEC: Add tests for data_explorer[id] rake command

* Test if a single query is hidden correctly
    * Expect length of query list to not be modified
    * Expect array of hidden queries to have exactly 1 element
    * Expect that one element to have the same ID as the one invoked to
    be hidden
* Test if multiple queries are hidden correctly
    * Expect length of query list to not be modified
    * Expect array of hidden queries to have the number of elements
    equal to the number invoked to be hidden
    * Expect the elements to have the same ID as the ones invoked to be
    hidden
* Test if a query exists in PluginStore
    * Expect query list to be empty

* DEV: Clear pre-existing tasks before redefining

* This prevents double invocation when user invokes the task once

* SPEC: Add tests for unhide_query rake task

* Test if a single query unhides correctly
    * Expect length of query list to not be modified
    * Expect array of hidden queries to have exactly 1 element after
    unhiding 1 of 2 queries
    * Expect remaining element to be hidden
* Test if multiple queries unhide correctly
    * Expect length of query list to not be modified
    * Expect array of hidden queries to have exactly 1 element after
    unhiding 3 of 4 queries
    * Expect remaining element to be hidden
* Test if a query exists in PluginStore
    * Expect query list to not be modified

* SPEC: Add tests for hard_delete rake task

* Test if a single query hard deletes correctly
    * Expect length of query list to be shorter by 1
    * Expect array of hidden queries to have exactly 1 element after
    hard deleting 1 of 2 queries
    * Expect 1 remaining hidden element
* Test if multiple queries hard delete correctly
    * Expect length of query list to be shorter by 3 after hard deleting
    3 of 4 queries
    * Expect array of hidden queries to have exactly 1 element after
    hard deleting 3 of 4 queries
    * Expect 1 remaining hidden element
* Test if a query exists in PluginStore
    * Expect hidden query list to not be modified
* Test if a query is not hidden
    * Expect query list to not be modified

* UX: Favor newline char in place of puts for logs

* Condensed console logs to output newline char instead of another puts
statement (reduces number of lines used significantly)
2020-07-29 16:50:24 +10:00
Vinoth Kannan 96a8d1862e FIX: limit maximum number of CSV rows correctly.
bbea8884db
2020-02-24 10:53:48 +05:30
Vinoth Kannan bbea8884db FIX: `limit` parameter value `ALL` should work for JSON exports.
183bc26763
2020-02-24 10:28:22 +05:30
Vinoth Kannan 183bc26763 DEV: set limit for maximum no of rows in CSV exports. 2020-02-20 23:34:15 +05:30
Arpit Jalan 16ea1c55a9 FIX: download CSV feature was not working for group reports 2020-01-21 15:16:15 +05:30
tshenry 6393831b0b FEATURE: Additional enums (#45)
Data explorer displays special information about various enums, this flags more fields that we know are enums leading to a clearer UX.
2019-12-09 14:20:34 +11:00
Penar Musaraj ffe315c4a2 Rubocop redundant return fix 2019-11-14 15:07:58 -05:00
Justin DiRose 48f0e2b982
FIX: Return all groups instead of truncated list (#42) 2019-11-14 12:39:55 -06:00
Joffrey JAFFEUX 4196321e41
FIX: ensures group_ids are not "" or nil (#39) 2019-10-16 12:43:10 +02:00
Arpit Jalan 2acab3ba89 FIX: do not raise error if query does not have group_ids 2019-09-13 12:00:29 +05:30
romanrizzi 588391cb2f Fix broken spec and linting errors 2019-09-11 11:52:06 -03:00
Mark VanLandingham 30fe9289b8 Allow groups to access queries (#36)
* [WIP] group ids saving on new reports

* Add groups to default queries, and added tab connector

* group_ids set to empty array for default queries

* group reports route (in & and) action

* [WIP] created group reports show route/controller

* Find correct query in show route

* Removed empty array for group_ids in query file

* Add report show view, where users can run queries

* Removed unneeded commas from queries.rb

* Allow non-admin group members to access reports

* query-result component dynamic download url based on location

* Removed accidental changes, and corrected tab size

* Group members can add params to queries

* Specs for new QueryController actions

* remove "Inlude query plan" from group reports

* Run prettier

* return and return -> return render

Co-Authored-By: Robin Ward <robin.ward@gmail.com>

* [WIP] changes from review

* Remove weird [-1] group_ids logic, for a simply check for [] in query update action

* Added integration tests for group report access

* Using guardian for securing endpoints, and much improved specs

* Update assets/javascripts/discourse/components/group-reports-nav-item.js.es6

Co-Authored-By: Robin Ward <robin.ward@gmail.com>
2019-09-11 10:09:41 -04:00
Sam Saffron 29862defaa FEATURE: add support for _url to link to a url
This new feature means that if you name a column `xyz_url` then the return
value will be treated as a URL.

If you would like to name the link use the format `name,https://cnn.com`
2019-05-13 14:44:51 +10:00
Guo Xiang Tan 817a233cef Add frozen string literal comment to files. 2019-05-13 10:42:48 +08:00
Robin Ward 53ec9262a8 FIX: Support new Reviewable API if present 2019-03-13 11:14:01 -04:00
Rishabh 13ab013df2 FIX: Ensure that all query information persists after delete/un-delete operations
https://meta.discourse.org/t/data-explorer-created-by-missing/107195
2019-01-28 12:30:17 +05:30
Rishabh a3c9cd7363 FIX: Don't send extra_data when exporting results to JSON
The extra data is needed to render avatars and user metadata when rendering results in the browser,
we can skip this data for JSON exports to reduce bloat
2019-01-24 12:46:02 +05:30
Rishabh a285a38e9c FIX: Allow the Data Explorer API to set LIMIT to "ALL"
Fixes a bug that prevented returning unlimited rows.

Example request:
{{base_url}}/admin/plugins/explorer/queries/6/run?api_key={{api_key}}&api_username={{api_username}}&limit=ALL

From the PostgreSQL docs: "LIMIT ALL" is treated as no limit
https://www.postgresql.org/docs/current/static/sql-select.html#SQL-LIMIT
2019-01-23 16:18:06 +05:30
Rishabh 77d603098f DEV: rubocop improvements for plugin.rb 2019-01-21 15:54:21 +05:30
Rishabh 8720c2cd5c DEV: Replace hardcoded result limit with a module constant 2019-01-21 14:21:53 +05:30
Penar Musaraj 061322e53a Finalize FA5 fixes 2018-11-15 11:12:32 -05:00
Penar Musaraj 3d6743dd14 Add another FA5 icon 2018-11-08 12:01:50 -05:00
Penar Musaraj d05fb698d6 FA5 icon fix 2018-11-08 11:37:23 -05:00
David Taylor 17e649d645 DEV: Rename shadowed variable 2018-10-22 21:24:55 +01:00
Rishabh b352e747c7
FEATURE: Ship default queries with the Data Explorer
Load default queries from queries.rb and save when run.
Each time a query is run, it picks up changes from queries.rb.
2018-10-10 16:59:13 +05:30
Rishabh Nambiar f876cf66f1 Increase result limit from 250 to 1000 2018-09-18 11:24:37 +05:30
Rishabh Nambiar 316923f190 FEATURE: Show the number of results after running a query (limit 250) 2018-09-18 11:15:31 +05:30
Rishabh Nambiar 1b68847d21 FEATURE: Sort queries by last_run_at as default 2018-08-27 20:10:25 +05:30
Rishabh Nambiar 42b6dbbae2 FIX: Remove bad default query description and add placeholder instead 2018-08-19 10:24:53 +05:30
Arpit Jalan d9e7b438b4 do not save username since we are already saving user_id 2018-08-14 18:13:30 +05:30
Rishabh Nambiar 83b1fcb54b Added User.find() & fixed scroll history bug 2018-08-14 17:38:08 +05:30
Rishabh Nambiar 6e806cc1df Added clickable rows, default query sorting by id and clickable usernames 2018-08-14 17:38:08 +05:30
Rishabh Nambiar e341d5a6fa List all previous queries on Data Explorer homepage 2018-08-14 17:38:08 +05:30
Sam 37be7a54f0 FEATURE: Upgrade to mini_sql
WARNING if you are on the stable branch of Discourse use the stable
branch of data explorer
2018-07-13 12:42:11 +10:00
Régis Hanol 7c94f98436 FIX: prevent creation of query with an empty name 2018-05-09 22:23:56 +02:00
Gerhard Schlager 4de3b1dcb9 Sort queries alphabetically 2018-02-23 15:01:50 +01:00
Gerhard Schlager bd28b6bbf2 FIX: CR LF prevented type validation for ints 2017-12-18 13:46:02 +01:00
Stephen Chung 0607abe2fd
Avoid exception when object.user is nil 2017-12-07 15:08:44 +08:00
Arpit Jalan 07cb0005b0 FIX: exporting result in CSV format was broken 2017-10-04 17:50:14 +05:30
Guo Xiang Tan dd6ed13a9a Remove use of deprecated `Fixnum`. 2017-09-04 14:06:19 +08:00
Guo Xiang Tan 6bb3d86d55 Use `before_action` for Rails 5 compatibility. 2017-09-04 13:59:06 +08:00
Guo Xiang Tan cc379ab757 Fix rubocop offenses. 2017-08-02 14:42:49 +09:00
Guo Xiang Tan 195931c6ba FIX: Avoid checking for a template when setting an etag. 2016-03-26 13:48:57 +08:00
Kane York 9956b9833e Add topic,category,group,reltime rendering 2015-09-21 14:43:23 -07:00
Kane York d4d541747e Add a statement timeout so you can't tie up the serve 2015-09-14 16:08:30 -07:00
Kane York 86a3d16ad4 Deprecations fixes 2015-09-14 15:34:57 -07:00
Kane York 7d50fbbdae Merge branch 'refactor' into 'master'
Conflicts:
	renamed assets/javascripts/discourse/adapters/query.js.es6
2015-08-25 21:39:22 -07:00