Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rated Point Sum のバグ #1464

Closed
sortA0329 opened this issue Jan 29, 2024 · 1 comment · May be fixed by #1465
Closed

Rated Point Sum のバグ #1464

sortA0329 opened this issue Jan 29, 2024 · 1 comment · May be fixed by #1465

Comments

@sortA0329
Copy link

僕のプロフィールのRated Point Sumの値がとても大きな値(現在1509389050)になっています。Rated Point Rankingは正常なようです。

@hotate29
Copy link
Contributor

hotate29 commented Feb 8, 2024

asprocon10_a(37078900点)とasprocon10_b(1472090400点)の得点が足された結果かなと思います。

このissue(#1429)の問題がフロントエンドでも起きているようです。コンテストがAlgo Ratedかを判定する条件が変更され、バックエンド側のコードが更新された(#1439)のですが、フロントエンド側にあった同様の処理が漏れてしまったようです。これを修正したらとりあえず解決できそうです。

export const isRatedContest = (
contest: Contest,
problemCount: number
): boolean => {
return (
contest.rate_change !== "-" &&
contest.start_epoch_second >= AGC_001_START &&
problemCount >= 2
);
};

AchievementのタブでRated Point Sumを取得する処理では、isRatedContest()を使って自前で計算しています。

const ratedProblemIds = new Set(
contests
.flatMap((contest) => {
const contestProblems = contestToProblems.get(contest.id);
const isRated = isRatedContest(contest, contestProblems?.length ?? 0);
return isRated && contestProblems ? contestProblems : [];
})
.map((problem) => problem.id)
);
const acceptedRatedSubmissions = userSubmissions
.filter((s) => isAccepted(s.result))
.filter((s) => ratedProblemIds.has(s.problem_id));
acceptedRatedSubmissions.sort((a, b) => a.id - b.id);
const ratedPointMap = new Map<ProblemId, number>();
acceptedRatedSubmissions.forEach((s) => {
ratedPointMap.set(s.problem_id, s.point);
});
const ratedPointSum = Array.from(ratedPointMap.values()).reduce(
(sum, point) => sum + point,
0
);

これとは別に、この部分でバックエンドからRated Point Sumの順位を取得しています。レスポンスにはRated Point Sumが含まれるので、こっちを使うようにしても良いかもしれません。

const sumRankEntry = useUserSumRank(props.userId);
const sumRank = sumRankEntry.data?.rank;

impl UserRankSelector for RatedPointSumRanking {
type Request = UserRankRequest;
type Response = UserRankResponse;
async fn fetch(
pool: web::Data<PgPool>,
query: Self::Request,
) -> Result<Option<Self::Response>> {
let point_sum = pool.get_users_rated_point_sum(&query.user).await;
let point_sum = match point_sum {
Some(point_sum) => point_sum,
None => return Ok(None),
};
let rank = pool
.get_rated_point_sum_rank(point_sum)
.await
.map_err(error::ErrorInternalServerError)?;
let response = UserRankResponse {
count: point_sum,
rank,
};
Ok(Some(response))
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants