# 如何在数据资源管理器中删除系统查询？

**URL:** https://meta.discourse.org/t/how-to-delete-system-queries-in-data-explorer/147524
**Category:** UX
**Tags:** data-explorer, completed
**Created:** [2020年四月10日 08:30 UTC](https://meta.discourse.org/t/how-to-delete-system-queries-in-data-explorer/147524 "2020-04-10T08:30:42Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Konrad\_Sopala](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/konrad_sopala/32/167014_2.png) [@Konrad\_Sopala](https://meta.discourse.org/u/Konrad_Sopala)
#### Post date: [2020年四月10日 08:30 UTC](https://meta.discourse.org/t/how-to-delete-system-queries-in-data-explorer/147524/1 "2020-04-10T08:30:42Z")

</div>

你好！

我们发现在数据资源管理器中，系统查询并不实用。我们能否删除它们？感谢您的帮助！

---

<div class="post-metadata">

### Author: ![maiki](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maiki/32/233950_2.png) [@maiki](https://meta.discourse.org/u/maiki)
#### Post date: [2020年四月10日 19:27 UTC](https://meta.discourse.org/t/how-to-delete-system-queries-in-data-explorer/147524/2 "2020-04-10T19:27:47Z")

</div>

> [@Konrad\_Sopala](#):
>
> 我们能否以某种方式删除它们？

我不这么认为，但我想指出它们是按正在运行的查询排序的。我所有的系统查询都在底部，也许你可以接受这一点。🙂

---

<div class="post-metadata">

### Author: ![Konrad\_Sopala](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/konrad_sopala/32/167014_2.png) [@Konrad\_Sopala](https://meta.discourse.org/u/Konrad_Sopala)
#### Post date: [2020年四月13日 09:43 UTC](https://meta.discourse.org/t/how-to-delete-system-queries-in-data-explorer/147524/3 "2020-04-13T09:43:47Z")

</div>

谢谢，但不幸的是这完全没帮助

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2020年七月9日 07:54 UTC](https://meta.discourse.org/t/how-to-delete-system-queries-in-data-explorer/147524/4 "2020-07-09T07:54:57Z")

</div>

很遗憾，我们在此不支持删除功能。我们会将此建议纳入考虑，我们或许可以支持“软删除”功能，从而隐藏特定的系统查询。所有查询均已建立索引。

---

<div class="post-metadata">

### Author: ![Konrad\_Sopala](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/konrad_sopala/32/167014_2.png) [@Konrad\_Sopala](https://meta.discourse.org/u/Konrad_Sopala)
#### Post date: [2020年七月9日 08:20 UTC](https://meta.discourse.org/t/how-to-delete-system-queries-in-data-explorer/147524/5 "2020-07-09T08:20:20Z")

</div>

听起来很棒！期待该功能的发布，它将彻底解决数据探索器中未使用查询带来的混乱。谢谢！

---

<div class="post-metadata">

### Author: ![RickyC0626](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rickyc0626/32/185743_2.png) [@RickyC0626](https://meta.discourse.org/u/RickyC0626)
#### Post date: [2020年七月29日 16:10 UTC](https://meta.discourse.org/t/how-to-delete-system-queries-in-data-explorer/147524/8 "2020-07-29T16:10:00Z")

</div>

您现在可以“删除”所有查询，包括系统查询。从用户角度来看，删除按钮的功能保持不变，但只会对查询进行软删除（即隐藏）。此外，如果您需要，还可以使用以下 rake 任务：

- 查看哪些查询已被隐藏

```plaintext
rake data_explorer:list_hidden_queries

```

- 按 ID 隐藏可见的查询（一个或多个）

```plaintext
rake data_explorer[id]
rake data_explorer[id1,id2,id3]

rake data_explorer[1]
rake data_explorer[-1,2,-3]

```

- 按 ID 取消隐藏已隐藏的查询（一个或多个）

```plaintext
rake data_explorer:unhide_query[id]
rake data_explorer:unhide_query[id1,id2,id3]

rake data_explorer:unhide_query[1]
rake data_explorer:unhide_query[-1,2,-3]

```

- 按 ID 硬删除已隐藏的查询（一个或多个）

```plaintext
rake data_explorer:hard_delete[id]
rake data_explorer:hard_delete[id1,id2,id3]

rake data_explorer:hard_delete[1]
rake data_explorer:hard_delete[-1,2-3]

```

> <https://github.com/discourse/discourse-data-explorer/commit/dcfb92d7f895bf749cbe962997a15d2961d2272f>
>
> \* FEATURE: Add hide button (toggleable) for all queries (frontend only)
> 
> \* Swi…tches 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 a8771d2ad57083a91b7130df807fa54c26205d11.
> 
> 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)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2020年七月30日 00:43 UTC](https://meta.discourse.org/t/how-to-delete-system-queries-in-data-explorer/147524/9 "2020-07-30T00:43:22Z")

</div>

@Konrad_Sopala 通知您，该变更将在大约 10 分钟后在您的实例上生效！

🎊 感谢 @RickyC0626 提供的功能！

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2020年七月31日 08:00 UTC](https://meta.discourse.org/t/how-to-delete-system-queries-in-data-explorer/147524/10 "2020-07-31T08:00:19Z")

</div>

此主题在 31 小时后自动关闭。不再允许新回复。
