Skip to content

Commit 307f0ef

Browse files
authored
Merge pull request #1262 from kenkoooo/fix/fetch-loop
fix: use epoch_second to sort submissions instead of id
2 parents c7689b2 + a4b93f0 commit 307f0ef

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

atcoder-problems-frontend/src/database/SubmissionsDB.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,13 @@ const fetchNewSubmissions = async (
3333
fromSecond: number
3434
): Promise<Submission[]> => {
3535
const newSubmissions = [] as Submission[];
36-
// eslint-disable-next-line no-constant-condition
37-
while (true) {
36+
for (;;) {
3837
const fetched = await fetchPartialUserSubmissions(userId, fromSecond);
3938
if (fetched.length === 0) {
4039
break;
4140
}
4241
newSubmissions.push(...fetched);
43-
newSubmissions.sort((a, b) => a.id - b.id);
42+
newSubmissions.sort((a, b) => a.epoch_second - b.epoch_second);
4443
fromSecond = newSubmissions[newSubmissions.length - 1].epoch_second + 1;
4544
}
4645
return newSubmissions;
@@ -57,7 +56,7 @@ export const fetchSubmissionsFromDatabaseAndServer = async (userId: UserId) => {
5756
const submissions = await loadAllData<Submission[]>(db, OBJECT_STORE);
5857

5958
console.log(`Loaded ${submissions.length} submissions from DB`);
60-
submissions.sort((a, b) => a.id - b.id);
59+
submissions.sort((a, b) => a.epoch_second - b.epoch_second);
6160

6261
const lastSecond =
6362
submissions.length > 0

0 commit comments

Comments
 (0)