# 向版主开放数据浏览器功能

**URL:** https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613
**Category:** Feature
**Tags:** pr-welcome, data-explorer
**Created:** [2018年三月27日 07:33 UTC](https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613 "2018-03-27T07:33:18Z")
**Posts on this page:** 19
**Page:** 2

<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: [2019年九月3日 03:20 UTC](https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613/25 "2019-09-03T03:20:27Z")

</div>

看起来太棒了！👏

你能确认参数是否也能正常工作吗？

---

<div class="post-metadata">

### Author: ![markvanlan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markvanlan/32/160087_2.png) [@markvanlan](https://meta.discourse.org/u/markvanlan)
#### Post date: [2019年九月3日 03:34 UTC](https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613/26 "2019-09-03T03:34:17Z")

</div>

是的，如果查询包含参数，它们会显示在用户界面中。

---

<div class="post-metadata">

### Author: ![markvanlan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markvanlan/32/160087_2.png) [@markvanlan](https://meta.discourse.org/u/markvanlan)
#### Post date: [2019年九月3日 13:25 UTC](https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613/27 "2019-09-03T13:25:30Z")

</div>

我弄错了，params 目前无法正常工作。我今天会着手调查。

查询的适配器是一个管理员适配器，因此非管理员用户无法访问查询存储。我添加了非管理员可以调用的端点来获取查询 JSON，但该 JSON 似乎并未被转换为 Query 模型（当然，它们本就无法被转换），因此 params 逻辑并未执行。我推测需要一个非管理员的查询适配器？

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [2019年九月3日 14:34 UTC](https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613/28 "2019-09-03T14:34:37Z")

</div>

我在截图 #3 中看到了一个问题：既然现在有了有意义的非查询数据需要保存，您可能需要考虑恢复“保存但不运行”按钮。

* * *

啊，我没注意到您也导入了绿色的确认按钮。

---

<div class="post-metadata">

### Author: ![markvanlan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markvanlan/32/160087_2.png) [@markvanlan](https://meta.discourse.org/u/markvanlan)
#### Post date: [2019年九月3日 14:48 UTC](https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613/29 "2019-09-03T14:48:13Z")

</div>

绿色确认按钮仅保存而不执行，我认为“保存更改并运行”按钮理应实现这一功能。  
您的意思是“保存更改并运行”的行为应当变更，即不执行查询吗？

---

<div class="post-metadata">

### Author: ![markvanlan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markvanlan/32/160087_2.png) [@markvanlan](https://meta.discourse.org/u/markvanlan)
#### Post date: [2019年九月4日 23:10 UTC](https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613/30 "2019-09-04T23:10:40Z")

</div>

组成员现在可以运行带参数的查询了！

 ![48%20PM](https://global.discourse-cdn.com/meta/original/3X/3/c/3c119518345e84bdb104c24f50f9898fce1c80d5.png)

我无法运行测试（使用 `bundle exec rspec`），因此尚未为创建的新操作编写任何测试。有人能指出我漏掉了什么吗？错误信息是 `uninitialized constant DataExplorer`。

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2019年九月4日 23:17 UTC](https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613/31 "2019-09-04T23:17:40Z")

</div>

尝试运行 `LOAD_PLUGINS=1 RAILS_ENV=test bundle exec rspec`

---

<div class="post-metadata">

### Author: ![markvanlan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markvanlan/32/160087_2.png) [@markvanlan](https://meta.discourse.org/u/markvanlan)
#### Post date: [2019年九月4日 23:19 UTC](https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613/32 "2019-09-04T23:19:39Z")

</div>

> [@Falco](#):
>
> LOAD\_PLUGINS=1 RAILS\_ENV=test bundle exec rspec

是的，这样就可以了。谢谢！

---

<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: [2019年九月4日 23:24 UTC](https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613/33 "2019-09-04T23:24:55Z")

</div>

注意，我通常直接使用 `bin/rake autospec`，它会自动完成这些操作，你只需要保存 plugin.rb 或类似文件即可。

---

<div class="post-metadata">

### Author: ![markvanlan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markvanlan/32/160087_2.png) [@markvanlan](https://meta.discourse.org/u/markvanlan)
#### Post date: [2019年九月6日 00:52 UTC](https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613/34 "2019-09-06T00:52:47Z")

</div>

@sam，

您觉得群组报告中的“包含查询计划？”复选框怎么样？

这似乎是一个群组成员不需要访问的功能，应该将其移除。这个假设正确吗？

 ![41%20PM](https://global.discourse-cdn.com/meta/original/3X/d/9/d94bbcc71100c69c3733fe32288a9bd71d720f4f.png)

---

<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: [2019年九月6日 01:32 UTC](https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613/35 "2019-09-06T01:32:47Z")

</div>

同意，这是他们其实并不需要的信息

---

<div class="post-metadata">

### Author: ![markvanlan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markvanlan/32/160087_2.png) [@markvanlan](https://meta.discourse.org/u/markvanlan)
#### Post date: [2019年九月6日 23:01 UTC](https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613/36 "2019-09-06T23:01:51Z")

</div>

此内容已被移除，[PR](https://github.com/discourse/discourse-data-explorer/pull/36) 已准备好接受审查。

有两个测试用例失败，但在 master 分支上它们也会失败。如果你们希望，我可以在此 PR 中尝试修复这些问题：🤷‍♂️

---

<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: [2019年九月9日 02:52 UTC](https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613/37 "2019-09-09T02:52:10Z")

</div>

> [@markvanlan](#):
>
> 如果这能帮上忙，我可以在这份 PR 中修复这些问题。

非常欢迎！我们将很快进行审查，感谢您出色的工作。

---

<div class="post-metadata">

### Author: ![Grayden\_Shand](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/grayden_shand/32/166586_2.png) [@Grayden\_Shand](https://meta.discourse.org/u/Grayden_Shand)
#### Post date: [2020年二月7日 14:25 UTC](https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613/38 "2020-02-07T14:25:00Z")

</div>

我尝试使用此功能，但似乎添加到表单中的组无法保留，也就是说无法保存表单。

以下是我想与版主分享的查询截图：  
[![](https://global.discourse-cdn.com/meta/original/3X/a/c/acc4fd9104ecd31bbf7925dea85b858914edf37a.png) ](https://dl.dropboxusercontent.com/s/xypahit4idgoyu1/Screenshot%202020-02-07%2009.19.35.png?dl=0)

我按如下方式添加组：  
[![](https://global.discourse-cdn.com/meta/original/3X/3/4/34b3b6f273690a8b594c83a352f2568bf833c115.png) ](https://dl.dropboxusercontent.com/s/n0ld82rlcap8cbx/Screenshot%202020-02-07%2009.20.03.png?dl=0)

但刷新页面后，该组消失了：  
[![](https://global.discourse-cdn.com/meta/original/3X/8/6/86cbd00d2cec30ee5f94f7cba61eb3b2068c17c7.png) ](https://dl.dropboxusercontent.com/s/o2qio6v06senrra/Screenshot%202020-02-07%2009.20.41.png?dl=0)

在刷新之前编辑并“保存”查询对此也没有任何影响。此外，我还尝试分享其他查询，包括一些系统默认查询，但均无济于事。

---

<div class="post-metadata">

### Author: ![Grayden\_Shand](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/grayden_shand/32/166586_2.png) [@Grayden\_Shand](https://meta.discourse.org/u/Grayden_Shand)
#### Post date: [2020年二月7日 15:48 UTC](https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613/40 "2020-02-07T15:48:28Z")

</div>

更新一下：我发现另一个网站也能正常运行，看来问题与特定站点有关。

无论如何，如果 UI 也出现异常，我找到了一个变通方案：通过 API 向 `https://example.com/admin/plugins/explorer/queries/<query_id>` 发送 POST 请求，将组添加到查询中。

设置请求头，使用管理员用户的 API 密钥：

- `Api-Username`
- `Api-Key`
- `Content-Type` – application/json

设置请求体：

- `query[group_ids][]` – 允许访问此查询的组 ID 列表，以逗号分隔的字符串形式提供

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [2020年二月7日 16:27 UTC](https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613/42 "2020-02-07T16:27:43Z")

</div>

今天或周一会看一下

---

<div class="post-metadata">

### Author: ![Grayden\_Shand](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/grayden_shand/32/166586_2.png) [@Grayden\_Shand](https://meta.discourse.org/u/Grayden_Shand)
#### Post date: [2020年二月7日 16:36 UTC](https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613/43 "2020-02-07T16:36:55Z")

</div>

不紧急，  
谢谢 @j.jaffeux！

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [2020年二月10日 07:37 UTC](https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613/44 "2020-02-10T07:37:54Z")

</div>

这应该通过以下方式修复：

> <https://github.com/discourse/discourse-data-explorer/commit/df9e21911e6ee3145d56b25f377218f59df0e471>

感谢您的报告。

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [2020年二月12日 07:38 UTC](https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613/45 "2020-02-12T07:38:11Z")

</div>

此主题在最后一次回复后 2 天自动关闭。不再允许新回复。

[上一頁](https://meta.discourse.org/t/make-data-explorer-available-to-moderators/90613.md?page=1)
