Skip to content

Use delete_by_query to remove all duplicate favorite documents#1458

Open
oalders wants to merge 1 commit into
masterfrom
oalders/metacpan-api/delete-favorite
Open

Use delete_by_query to remove all duplicate favorite documents#1458
oalders wants to merge 1 commit into
masterfrom
oalders/metacpan-api/delete-favorite

Conversation

@oalders
Copy link
Copy Markdown
Member

@oalders oalders commented Apr 2, 2026

Prod has cases where duplicate favorite documents exist for the same
(user, distribution) pair with different authors -- I don't know exactly
why this is. The previous delete handler used get(), which computes a
single composite ID, deletes one document and leaves orphans behind.
This is possibly why users sometimes reported removing a ++ but not
actually being able to delete it. Switch to search + delete_by_query to
remove all matching documents and purge cache keys for every affected
author.

@oalders
Copy link
Copy Markdown
Member Author

oalders commented Apr 2, 2026

I should note that I'm not sure why author keys need to be purged, but the previous code already did this.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.22%. Comparing base (0a7f2f5) to head (93cb804).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1458      +/-   ##
==========================================
+ Coverage   62.16%   62.22%   +0.06%     
==========================================
  Files         137      137              
  Lines        4393     4400       +7     
  Branches      659      658       -1     
==========================================
+ Hits         2731     2738       +7     
- Misses       1410     1412       +2     
+ Partials      252      250       -2     
Files with missing lines Coverage Δ
lib/MetaCPAN/Server/Controller/User/Favorite.pm 92.85% <100.00%> (+16.66%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@oalders oalders force-pushed the oalders/metacpan-api/delete-favorite branch 2 times, most recently from 00b03d9 to 93cb804 Compare April 2, 2026 15:42
Prod has cases where duplicate favorite documents exist for the same
(user, distribution) pair with different authors -- I don't know exactly
why this is. The previous delete handler used get(), which computes a
single composite ID, deletes one document and leaves orphans behind.
This is possibly why users sometimes reported removing a ++ but not
actually being able to delete it. Switch to search + delete_by_query to
remove all matching documents and purge cache keys for every affected
author.
@oalders oalders force-pushed the oalders/metacpan-api/delete-favorite branch from 93cb804 to eb60c1f Compare April 24, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant