Conservatively announce rating changes

This commit is contained in:
Natsu Kagami 2020-02-17 12:15:11 -05:00
parent 4f08eb0caf
commit c64a95094f
Signed by: nki
GPG key ID: 73376E117CD20735

View file

@ -46,11 +46,7 @@ fn update_user(
.next()
.ok_or(CommandError::from("Not found"))?;
let rating_changes = {
let mut v = info.rating_changes(reqwest)?;
v.reverse();
v
};
let rating_changes = info.rating_changes(reqwest)?;
let mut channels_list: Option<Vec<ChannelId>> = None;
cfu.last_update = Utc::now();
@ -86,10 +82,17 @@ fn update_user(
let rating_changes = match cfu.last_contest_id {
None => rating_changes,
Some(v) => rating_changes
.into_iter()
.take_while(|rc| rc.contest_id != v)
.collect(),
Some(v) => {
let mut v: Vec<_> = rating_changes
.into_iter()
// Skip instead of take because sometimes Codeforces
// performs rollback.
.skip_while(|rc| rc.contest_id != v)
.skip(1)
.collect();
v.reverse();
v
}
};
cfu.last_contest_id = rating_changes