open-sauced / pizza-cli

A CLI for all things OpenSauced
MIT License
32 stars 9 forks source link

feat: `pizza generate insight` command #179

Closed jpmcb closed 6 days ago

jpmcb commented 6 days ago

Description

Refactors the existing interactive flow from pizza generate codeowners (after the codeowners file has been created) into its own command:

❯ ./build/pizza generate insight .
[jpmcb nickytonline brandonroberts zeucapua]
Do you want to add these codeowners to an OpenSauced Contributor Insight? (y/n): y
Adding codeowners to contributor insight

Access Contributor Insight on OpenSauced:
https://app.opensauced.pizza/workspaces/8718805b-66b8-4da5-887d-c37366b8e0da/contributor-insights/dfa8e053-f68a-47e9-ae09-fc13579ca4a5

Related Tickets & Documents

Closes #176

Steps to QA

  1. Build locally with just build
  2. Run command with ./build/pizza generate insight . in a directory with a CODEOWNERS file

Tier (staff will fill in)

brandonroberts commented 6 days ago

The command works good for me. How does this handle attribution groups vs usernames? If I have an open-sauced/engineering group of emails?

jpmcb commented 6 days ago

How does this handle attribution groups vs usernames?

It doesn't. It just uses a regex to look for the @ handle in CODEOWNERS files, grabs those, and uses them in the payload to the API.

The v2/workspaces/:id/userLists/:list-id API endpoint throws out logins that are invalid or 404 from GitHub.

For example, this request to the API:

curl -X 'PATCH' \
  'https://api.opensauced.pizza/v2/workspaces/8718805b-66b8-4da5-887d-c37366b8e0da/userLists/157b6ce1-c50d-438a-8648-050fbf662854' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <redacted>' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Test test test",
  "is_public": false,
  "contributors": [
    {
      "login": "jpmcb"
    },
    {
      "login": "open-sauced/engineering"
    },
    {
      "login": "Brandon Roberts"
    }
  ]
}'

throws out the two logins that aren't actually logins.


Abit of a rough experience. In the future we could hit the v2/users endpoints to see if the list of users is valid or not and inform the users of the ones that are being ignored. But this works for MVP right now.