Fix contribution counting in changelog generator

This commit is contained in:
Héctor Ramón Jiménez 2025-12-03 06:13:46 +01:00
parent 8eb5577c5b
commit aa8c0c3f4c
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 23 additions and 12 deletions

View file

@ -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()))
});
}
}