open-sauced / app

🍕 Insights into your entire open source ecosystem.
https://pizza.new
Apache License 2.0
381 stars 202 forks source link

feat: Remove deprecated v2/lists/:id/contributors endpoint #3635

Closed jpmcb closed 5 days ago

jpmcb commented 5 days ago

Description

Uses v2/workspaces/:workspace-id/userLists/:list-id/contributors endpoint in favor of the deprecated v2/lists/:id/contributors endpoint in the API

Related Tickets & Documents

Related to #3627

Steps to QA

  1. Run API locally
  2. Run app locally
  3. Go to a workspace user list - list is populated correctly

Tier (staff will fill in)

netlify[bot] commented 5 days ago

Deploy Preview for oss-insights ready!

Name Link
Latest commit f462cf28510e6fd7a3b830d6c4b814120f6bf2eb
Latest deploy log https://app.netlify.com/sites/oss-insights/deploys/667b56ec7ffd340008b61960
Deploy Preview https://deploy-preview-3635--oss-insights.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] commented 5 days ago

Deploy Preview for design-insights ready!

Name Link
Latest commit f462cf28510e6fd7a3b830d6c4b814120f6bf2eb
Latest deploy log https://app.netlify.com/sites/design-insights/deploys/667b56ecbe8c230008d0fb2a
Deploy Preview https://deploy-preview-3635--design-insights.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

jpmcb commented 5 days ago

Added the oscr field for user list contributors. Now, this should be captured in the endpoint to enable rendering of the list:

Screenshot 2024-06-25 at 5 33 24 PM

cc - @zeucapua as you'll need this in the table when rendering / sorting. By default the v2/workspaces/:workspace-id/userLists/:list-id/contributors endpoint does not sort on the stored OSCR scores. But, you can pass in the orderedBy (which the only value that is currently supported is oscr) and orderDirection(where both ASC and DESC are supported) params like so to get an ordered list:

curl -X 'GET' \
  'http://localhost:3003/v2/workspaces/8d9f8ee1-b5dc-452c-b547-6cd2e375f1ec/userLists/ec4b11e1-6c99-4114-afcb-4d4f3b972dc5/contributors?page=1&limit=10&orderBy=oscr&orderDirection=DESC' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <redacted>'

I didn't implement the orderBy or orderDirection in this PR since this was mostly intended to correct for the deprecated API endpoint in the API.

This results in the sorted initial, paginated list:

{
  "data": [
    {
      "id": "dc51c9b3-1859-42f8-bbd8-eeced8fc8806",
      "user_id": 42211,
      "list_id": "ec4b11e1-6c99-4114-afcb-4d4f3b972dc5",
      "username": "brandonroberts",
      "created_at": "2024-04-05T02:35:57.323Z",
      "login": "brandonroberts",
      "oscr": 0.89375
    },

    // etc. etc. more data

    {
      "id": "84ed3764-5a0c-49a4-902b-fa3dffce53f1",
      "user_id": 112971,
      "list_id": "ec4b11e1-6c99-4114-afcb-4d4f3b972dc5",
      "username": "jamessan",
      "created_at": "2024-05-21T20:50:09.395Z",
      "login": "jamessan",
      "oscr": 0.16000000000000003
    },
  ],
  "meta": {
    "page": 1,
    "limit": 10,
    "itemCount": 11,
    "pageCount": 2,
    "hasPreviousPage": false,
    "hasNextPage": true
  }
}