mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-16 07:18:54 +00:00
Conservatively announce rating changes
This commit is contained in:
parent
4f08eb0caf
commit
c64a95094f
1 changed files with 12 additions and 9 deletions
|
@ -46,11 +46,7 @@ fn update_user(
|
||||||
.next()
|
.next()
|
||||||
.ok_or(CommandError::from("Not found"))?;
|
.ok_or(CommandError::from("Not found"))?;
|
||||||
|
|
||||||
let rating_changes = {
|
let rating_changes = info.rating_changes(reqwest)?;
|
||||||
let mut v = info.rating_changes(reqwest)?;
|
|
||||||
v.reverse();
|
|
||||||
v
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut channels_list: Option<Vec<ChannelId>> = None;
|
let mut channels_list: Option<Vec<ChannelId>> = None;
|
||||||
cfu.last_update = Utc::now();
|
cfu.last_update = Utc::now();
|
||||||
|
@ -86,10 +82,17 @@ fn update_user(
|
||||||
|
|
||||||
let rating_changes = match cfu.last_contest_id {
|
let rating_changes = match cfu.last_contest_id {
|
||||||
None => rating_changes,
|
None => rating_changes,
|
||||||
Some(v) => rating_changes
|
Some(v) => {
|
||||||
.into_iter()
|
let mut v: Vec<_> = rating_changes
|
||||||
.take_while(|rc| rc.contest_id != v)
|
.into_iter()
|
||||||
.collect(),
|
// 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
|
cfu.last_contest_id = rating_changes
|
||||||
|
|
Loading…
Add table
Reference in a new issue