Repository navigation
Conversation
… each pledge Contributors can split their weekly hours on their profile between their sponsors and their own time. The pledge total still added each contributor's full profile total to every pledge that sponsors them, and the stats counted their own time as company-sponsored. Read the splits in one query, count only the pledge's share toward the pledge, and count the own-time part of a company-sponsored contributor's split as self-sponsored in the stats snapshot. Without a split, the full total counts as before. Fixes WordPress#72.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #72.
Contributors can now split their weekly hours on their profile, between each sponsor and their own time. The pledge side still adds each contributor's full profile total to every pledge that sponsors them. So own time counts as sponsored, and a contributor with two sponsors adds their full total to both pledges.
For example, my profile form submits
wporg_5ftf_hours[296004]=4for the ShifteQ pledge,wporg_5ftf_hours[self]=2for my own time, andfield_29=6as the total. The ShifteQ pledge counts all 6, so it shows 9 hours per week instead of 7.What changes
XProfile\get_contributor_hours_splits()reads the splits for a list of users in one query.get_aggregate_contributor_data_for_pledge()counts only the hours a contributor gives through that pledge, when they have a split. The pledge sentences, the cached5ftf_pledge-total-hoursmeta and the sort by hours all use it, so they follow.Stats\get_snapshot_data()counts theselfpart of a company-sponsored contributor's split as self-sponsored hours.Not changed: contributor and team counts, the contributor report (it still shows each contributor's total), and
remove_contributor().One thing to confirm
The split is saved by profiles.wordpress.org, and that code is not public. Going by the form field names, I assumed it is stored as user meta
wporg_5ftf_hours, an array likearray( 296004 => 4, 'self' => 2 ). @obenland, can you confirm where it is stored? If it is somewhere else, only the split reader should need to change. Until then the code finds no split and every number stays as it is today, so nothing gets worse.Related: #201 asked for the split on the profile, and #372 is about attributing contributions to more than one sponsor.
Testing
test-xprofile.phpandtest-stats.php. Four of them fail before the fix. The other three guard today's behaviour (no split, an empty split, a split above the total) and pass on both sides. Full suite: 53 tests, green, run twice.phpcsshows no new warnings on the changed files.AI assistance: Claude Code and Codex helped with the investigation, tests and wording. I reviewed the code and the test results, and I take responsibility for the change.