Skip to content
This repository has been archived by the owner on Jul 5, 2021. It is now read-only.

Commit

Permalink
clamp recent 10 value
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSnowfield committed Apr 28, 2021
1 parent 2abf0f3 commit 59b7102
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion source/publicapi/v4/user/best30.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,13 @@ const do_fetch_userbest30 =
// calculate best30 and recent10 average value
// return zero when user ptt is negative
const _best30_avg: number = _best30_sum / 30;
const _recent10_avg: number = userinfo.rating == -1 ? 0 : (userinfo.rating / 100) * 4 - _best30_avg * 3;
let _recent10_avg: number = userinfo.rating == -1 ? 0 : (userinfo.rating / 100) * 4 - _best30_avg * 3;

// clamp minimum value
if (_recent10_avg < 0) {
_recent10_avg = 0;
syslog.w(TAG, 'Recent 10 average value less than 0.');
}

// Save all records that have been searched
arcrecord_update(userinfo.user_id, _arc_records)
Expand Down

0 comments on commit 59b7102

Please sign in to comment.