Hi, I think it would make it easier for admins to edit data explorer queries if it was easier to find Category and Group IDs. If this information was made visible to accounts with admin status it wouldn’t bother most people while making it simple to find for those who need access.
Alternatively, in the meantime, if there are already easy ways to find Category and Group IDs, I’m eager to learn how to find this information.
1 个赞
I’ll admit it’s not super easy to find if you don’t know where to look, but here’s a couple ways:
Data Explorer query:
SELECT name, id FROM categories ORDER BY name
via categories.json
curl https://meta.discourse.org/categories.json | jq '.category_list.categories[] | [.name,.id]'`
…info for all categories…
curl https://meta.discourse.org/categories.json | jq '.category_list.categories[] | select(.name == "feature").id'
2
via the JS console in the browser, e.g.:
> Discourse.Category.findBySlug('feature').id
2
13 个赞
simon
2019 年6 月 26 日 23:18
3
For Data Explorer queries, you can use a pattern similar to the WHERE statement in this query to avoid having to lookup category or group ids:
--[params]
-- string :category_name
SELECT
id AS topic_id
FROM topics t
WHERE t.category_id = (SELECT id FROM categories WHERE name = :category_name)
7 个赞
jericson
(Jon Ericson)
2024 年1 月 25 日 17:07
4
我顶一下这个帖子,因为我也有同样的问题。对于分类,查看 URL 相对容易:
https://meta.discourse.org/c/announcements/67
^^
但我找不到任何类似群组的东西。最理想的位置是在群组个人资料页面 (/g/[group_name]/manage/profile) 的某个地方。当然,这也不是什么大问题(数据浏览器是我的安全毯),但在使用 API 时确实很麻烦。
RGJ
(Richard - Communiteq)
2024 年1 月 25 日 17:10
5
对于任何内部内容,你只需在 URL 后附加 .json。对于那些棘手的帖子 ID 也同样适用。
2 个赞
我建议为数据浏览器添加更多类似 user_id 的参数,例如这个 Feature request for groups:
I’d love to be able to specify something like this:
-- [params]
-- groups.id :group_id
to get a parameter input that’s a dropdown of groups. I’ve named the value group_id here because I assume that’s what such a dropdown would give me.
5 个赞