Fix: Category Hierarchy and Persistent Multi-Category Contributions #40
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Contributions that belong to multiple categories were not persisting correctly across runs:
Root Causes & Solutions
1. Stale Commit Cache (Turn 2)
Issue:
getFirstCommitDetails()cached "no commits found" (null) keyed only by PR URL. On re-fetch, the stale null entry prevented re-checking when new commits were pushed later.Solution (
scripts/github-api-fetchers.js):prUpdatedAtparameter ingetFirstCommitDetails()updated_attimestampprUpdatedAtmatches current PRupdated_at{ firstCommitDate: null, commitCount: 0, prUpdatedAt }instead of null to distinguish "checked and found nothing" from "not checked"pr.updated_at/item.updated_atto all call sitesif (commitDetails)toif (commitDetails && commitDetails.firstCommitDate)to properly handle explicit null caches2. Multi-Category Persistence & Deduplication (Turn 2-3)
Issue: Merge logic didn't preserve multi-category membership or applied incorrect deduplication rules.
Solution (
scripts/main.js):pullRequests→reviewedPrs/coAuthoredPrs→collaborationsglobalLoadedByMap to track which categories each URL belongs toreviewedPrs+coAuthoredPrs)Validation
Test Case 1: PR #433 (mautic/user-documentation#433)
reviewedPrs✅ andcoAuthoredPrs✅Test Case 2: Lost Collaborations Recovered
Three collaborations (#115, #292, #111) that disappeared during earlier iterations:
coAuthoredPrs✅coAuthoredPrs✅coAuthoredPrs✅Test Case 3: No Unwanted Duplicates
Verified no cross-category duplicates exist between:
pullRequests↔reviewedPrs✅pullRequests↔collaborations✅issues↔ any other category ✅collaborations↔reviewedPrs/coAuthoredPrs✅Files Changed
scripts/github-api-fetchers.js: UpdatedgetFirstCommitDetails()to useprUpdatedAtin cache keyscripts/main.js: Replaced deduplication logic with category hierarchy enforcement