Charcoal-SE / metasmoke

Web dashboard for SmokeDetector.
https://metasmoke.erwaysoftware.com
Creative Commons Zero v1.0 Universal
43 stars 34 forks source link

Add user route to API for specific user types #167

Closed AWegnerGitHub closed 7 years ago

AWegnerGitHub commented 7 years ago

I'd like a user route in the API that is similar to the Stack Exchange users/moderators route. It's be helpful to have a route (or routes) that can quickly pull users of the main roles without needing to parse through a huge list of users to check each one individually:

The filters need to apply to this as well, so that we can associate the various chat_id fields with the users too.

AWegnerGitHub commented 7 years ago

It looks like there is already a route for the Code Privileges permission.

https://github.com/Charcoal-SE/metasmoke/blob/master/app/controllers/api_controller.rb#L133

Undo1 commented 7 years ago

Done & deployed. Use like so:

GET /api/users?key=...

Returns all users. Accepts filter.

GET /api/users?key=...&role=developer

Returns all users with the developer role:

items: [
 {
  id: 1,
  username: "Undo",
  stackexchange_chat_id: 73046,
  meta_stackexchange_chat_id: 215468,
  stackoverflow_chat_id: 1849664,
  stack_exchange_account_id: 1703573
 },
 {
  id: 7,
  username: "ArtOfCode",
  stackexchange_chat_id: 121520,
  meta_stackexchange_chat_id: 262823,
  stackoverflow_chat_id: 3160466,
  stack_exchange_account_id: 3457374
 }
]

Also accepts filter. role accepts any valid Role name - currently:

    [0] "reviewer",
    [1] "admin",
    [2] "code_admin",
    [3] "developer",
    [4] "flagger",
    [5] "core"