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 日午後 11: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 日午後 5:07
4
このトピックを再度上げます。私も同じ質問をしていたからです。カテゴリについては、URLを見れば比較的簡単です。
https://meta.discourse.org/c/announcements/67
^^
しかし、グループについてはそのようなものが見つかりません。理想的な場所は、グループプロファイルページ(/g/[group_name]/manage/profile)のどこかでしょう。もちろん、大した問題ではありません(Data Explorerが私のセーフティネットです)が、APIを操作している ときには不便です。
RGJ
(Richard - Communiteq)
2024 年 1 月 25 日午後 5: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