From aa8c0c3f4c074a4c7e1701291ab18bded9d8cb70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Wed, 3 Dec 2025 06:13:46 +0100 Subject: [PATCH] Fix contribution counting in `changelog` generator --- CHANGELOG.md | 14 +++++++------- examples/changelog/src/changelog.rs | 21 ++++++++++++++++----- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b4b22f9..bb90f293 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -280,6 +280,7 @@ Many thanks to... - @alex-ds13 - @B0ney - @bbb651 +- @EmmanuelDodoo - @JL710 - @kenz-gelsoft - @mfreeborn @@ -288,7 +289,6 @@ Many thanks to... - @13r0ck - @airstrike - @bungoboingo -- @EmmanuelDodoo - @karolisr - @Remmirad - @semiversus @@ -296,9 +296,11 @@ Many thanks to... - @xosxos - @Zarthus - @7h0ma5 +- @7sDream - @Adam-Ladd - @AMS21 - @Atreyagaurav +- @AustinEvansWX - @Azorlogh - @berserkware - @biglizards @@ -312,6 +314,7 @@ Many thanks to... - @DavidAguilo - @dcz-self - @dejang +- @dependabot[bot] - @EleDiaz - @ellieplayswow - @Exidex @@ -325,6 +328,7 @@ Many thanks to... - @ids1024 - @iMohmmedSA - @Integral-Tech +- @inthehack - @jakobhellermann - @janTatesa - @jbirnick @@ -347,6 +351,7 @@ Many thanks to... - @lmaxyz - @mariinkys - @max-privatevoid +- @MichelleGranat - @misaka10987 - @mytdragon - @njust @@ -363,17 +368,12 @@ Many thanks to... - @sgued - @sopvop - @T-256 +- @tafia - @thorn132 - @tigerros - @tsuza - @vincenthz - @will-lynas -- @7sDream -- @AustinEvansWX -- @dependabot[bot] -- @inthehack -- @MichelleGranat -- @tafia ## [0.13.1] - 2024-09-19 ### Added diff --git a/examples/changelog/src/changelog.rs b/examples/changelog/src/changelog.rs index bf7920db..c9ff14ce 100644 --- a/examples/changelog/src/changelog.rs +++ b/examples/changelog/src/changelog.rs @@ -103,8 +103,6 @@ impl Changelog { let mut candidates = Contribution::list().await?; - dbg!(candidates.len()); - for candidate in &candidates { *changelog .contributions @@ -112,6 +110,12 @@ impl Changelog { .or_default() += 1; } + for author in &changelog.authors { + if !changelog.contributions.contains_key(author) { + changelog.contributions.insert(author.clone(), 1); + } + } + for reviewed_entry in changelog.entries() { candidates.retain(|candidate| candidate.id != reviewed_entry); } @@ -166,13 +170,20 @@ impl Changelog { target.push(item); + *self.contributions.entry(entry.author.clone()).or_default() += 1; + if entry.author != "hecrj" && !self.authors.contains(&entry.author) { self.authors.push(entry.author); } - self.authors.sort_by_key(|author| { - usize::MAX - - self.contributions.get(author).copied().unwrap_or_default() + self.authors.sort_by(|a, b| { + self.contributions + .get(a) + .copied() + .unwrap_or_default() + .cmp(&self.contributions.get(b).copied().unwrap_or_default()) + .reverse() + .then(a.to_lowercase().cmp(&b.to_lowercase())) }); } }