Skip to content

Conversation

@ecrupper
Copy link
Contributor

@ecrupper ecrupper commented Nov 14, 2025

Description

This PR is the implementation of transforming the User.Favorites slice to a relational table that maps user_ids to repo_ids with positioning.

This will allow for the UI to render user's favorite repos in their preferred order every time. Further, it prevents the issue of capping favorites at 5000 total characters.

This PR does not include the deprecation of the User.Favorites field. That will be a follow up PR.

Breaking Changes

New table favorites, which will have to be created with data inserted from the existing users table. This will have to be addressed in the migration.

Endpoints

POST /api/v1/user/favorites

curl -X POST -H 'content-type: application/json' -H "Authorization: Bearer $V_TOKEN" http://vela-server/api/v1/user/favorites -d '{"repo": "foo/bar"}'

GET /api/v1/user/favorites

curl -H 'content-type: application/json' -H "Authorization: Bearer $V_TOKEN" http://vela-server/api/v1/user/favorites | jq 

[
  {
    "position": 1,
    "repo": "foo/bar"
  },
  {
    "position": 2,
    "repo": "foo/baz"
  },
  {
    "position": 3,
    "repo": "bar/foo"
  }
]

PUT /api/v1/user/favorites/:org/:repo

curl -X PUT -H 'content-type: application/json' -H "Authorization: Bearer $V_TOKEN" http://vela-server/api/v1/user/favorites/foo/bar -d '{"position": 1}'   

DELETE /api/v1/user/favorites/:org/:repo

curl -X DELETE -H 'content-type: application/json' -H "Authorization: Bearer $V_TOKEN" http://vela-server/api/v1/user/favorites/foo/bar  

@ecrupper ecrupper requested a review from a team as a code owner November 14, 2025 21:23
@codecov
Copy link

codecov bot commented Nov 14, 2025

Codecov Report

❌ Patch coverage is 61.34752% with 109 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.39%. Comparing base (35ef12a) to head (506f4e1).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
database/favorite/update_position.go 64.70% 9 Missing and 9 partials ⚠️
api/favorite/update.go 0.00% 16 Missing ⚠️
api/favorite/create.go 0.00% 15 Missing ⚠️
api/favorite/delete.go 0.00% 10 Missing ⚠️
api/favorite/list.go 0.00% 9 Missing ⚠️
database/favorite/favorite.go 52.63% 5 Missing and 4 partials ⚠️
database/favorite/delete.go 74.19% 4 Missing and 4 partials ⚠️
router/favorite.go 0.00% 7 Missing ⚠️
database/favorite/index.go 63.63% 2 Missing and 2 partials ⚠️
database/testutils/api_resources.go 0.00% 4 Missing ⚠️
... and 5 more

❌ Your project check has failed because the head coverage (58.39%) is below the target coverage (90.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1367      +/-   ##
==========================================
+ Coverage   58.36%   58.39%   +0.03%     
==========================================
  Files         645      660      +15     
  Lines       24864    25146     +282     
==========================================
+ Hits        14511    14684     +173     
- Misses       9681     9768      +87     
- Partials      672      694      +22     
Files with missing lines Coverage Δ
api/types/favorite.go 100.00% <100.00%> (ø)
database/database.go 67.44% <ø> (ø)
database/favorite/opts.go 100.00% <100.00%> (ø)
database/types/favorite.go 100.00% <100.00%> (ø)
router/user.go 0.00% <0.00%> (ø)
database/favorite/create.go 89.47% <89.47%> (ø)
database/favorite/list_user.go 88.88% <88.88%> (ø)
database/favorite/table.go 84.61% <84.61%> (ø)
database/resource.go 79.08% <75.00%> (-0.23%) ⬇️
database/favorite/index.go 63.63% <63.63%> (ø)
... and 9 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants