Group same contributions without URL, make grouping more precise
CI / Lint (pull_request) Successful in 51s
CI / Test (pull_request) Successful in 1m33s

This commit is contained in:
2026-07-26 17:22:53 +02:00
parent f7ee864071
commit 33a429c448
6 changed files with 135 additions and 63 deletions
+20 -5
View File
@@ -1,14 +1,29 @@
import ethers from 'ethers';
import { isEmpty } from '@ember/utils';
// Derives a stable grouping key for a contribution, so that contributions
// created for the same issue/pull request (one per contributor) can be
// linked together in the UI.
//
// Until we have identical IPFS documents for different contributions, we will
// use the URL as grouping key
// The key is a 6-char keccak256 prefix of a combination of fields:
// url (optional), description, date, amount, kind. When the URL is present
// (bot contributions) it is included; when absent (manual contributions)
// the remaining fields still produce a reliable key. All of description,
// date, amount, and kind must be present — if any is missing, the
// contribution is treated as a singleton (null key).
export default function contributionGroupingKey (contribution) {
let url = contribution ? contribution.url : null;
if (isEmpty(url)) return null;
return url;
if (!contribution) return null;
const { url, description, date, amount, kind } = contribution;
if (isEmpty(description) || isEmpty(date) || isEmpty(amount) || isEmpty(kind)) {
return null;
}
const input = isEmpty(url)
? `${description}|${date}|${amount}|${kind}`
: `${url}|${description}|${date}|${amount}|${kind}`;
return ethers.utils.id(input).slice(2, 8);
}