Expose Category and Group IDs to admins

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개의 좋아요

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개의 좋아요

같은 질문을 가지고 있어서 이 주제를 다시 올립니다. 카테고리의 경우 URL을 보면 비교적 쉽게 알 수 있습니다:

https://meta.discourse.org/c/announcements/67
                                           ^^ 

하지만 그룹에 대해서는 이와 같은 것을 찾을 수 없습니다. 이상적인 위치는 그룹 프로필 페이지(/g/[group_name]/manage/profile) 어딘가일 것입니다. 물론 큰 문제는 아닙니다(데이터 탐색기가 제 안전망이니까요), 하지만 API를 다룰 때는 번거로움이 됩니다.

내부적인 용도의 경우 URL 뒤에 .json을 붙여 사용하는 것만으로 충분합니다. 골치 아픈 포스트 ID에도 동일하게 적용됩니다.

6개의 좋아요

데이터 탐색기에 대해, 다음과 같은 user_id 스타일의 매개변수가 더 많아지기를 희망합니다. Contribute 그룹에 대한 기능 요청:

5개의 좋아요

좋은 팁 감사합니다 :smiley:

2개의 좋아요