Fix contribution counting in changelog generator
This commit is contained in:
parent
8eb5577c5b
commit
aa8c0c3f4c
2 changed files with 23 additions and 12 deletions
|
|
@ -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()))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue