Skip to content

Commit

Permalink
Merge pull request #3012 from Liu233w/fix-atcoder
Browse files Browse the repository at this point in the history
fix(crawler): fix deprecated atcoder api
  • Loading branch information
Liu233w authored Feb 8, 2024
2 parents f39d19f + c55a9f2 commit 31fa038
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
8 changes: 6 additions & 2 deletions crawler/__test__/crawlers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,12 @@ describe('atcoder', () => {

test('should work correctly', async () => {
const res = await atcoder(null, 'wata')
checkRes(res)
expect(res.solvedList).toContain('judge_update_202004_b')

expect(typeof res.solved).toBe('number')
expect(typeof res.submissions).toBe('number')

expect(res.solved).toBeGreaterThan(0)
expect(res.submissions).toBe(res.solved)
})

})
Expand Down
2 changes: 1 addition & 1 deletion crawler/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ crawlers:
title: AtCoder
description: |
API provided by kenkoooo (https://github.com/kenkoooo/AtCoderProblems).
It may take a while for the api to update user statistics.
Only AC number is supported
url: https://atcoder.jp
aizu:
meta:
Expand Down
15 changes: 4 additions & 11 deletions crawler/crawlers/atcoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,14 @@ module.exports = async function (config, username) {
// Thank @kenkoooo for the api
// Source code: https://github.com/kenkoooo/AtCoderProblems
const res = await request
.get('https://kenkoooo.com/atcoder/atcoder-api/results')
.get('https://kenkoooo.com/atcoder/atcoder-api/v3/user/ac_rank')
.query({ user: username })

const submissions = res.body.length
const acSet = new Set()
for (let item of res.body) {
if (item.result === 'AC') {
acSet.add(item.problem_id)
}
}
const acList = [...acSet]
const solved = res.body.count
const submissions = solved

return {
submissions,
solved: acList.length,
solvedList: acList,
solved,
}
}
4 changes: 2 additions & 2 deletions e2e/__test__/pages/__snapshots__/pages_snapshot.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4502,7 +4502,7 @@ exports[`/history/{historyId} 1`] = `
},
atcoder: {
title: "AtCoder",
description: "API provided by kenkoooo (https:\\u002F\\u002Fgithub.com\\u002Fkenkoooo\\u002FAtCoderProblems).\\nIt may take a while for the api to update user statistics.\\n",
description: "API provided by kenkoooo (https:\\u002F\\u002Fgithub.com\\u002Fkenkoooo\\u002FAtCoderProblems).\\nOnly AC number is supported\\n",
url: "https:\\u002F\\u002Fatcoder.jp"
},
aizu: {
Expand Down Expand Up @@ -8593,7 +8593,7 @@ exports[`/statistics 1`] = `
},
atcoder: {
title: "AtCoder",
description: "API provided by kenkoooo (https:\\u002F\\u002Fgithub.com\\u002Fkenkoooo\\u002FAtCoderProblems).\\nIt may take a while for the api to update user statistics.\\n",
description: "API provided by kenkoooo (https:\\u002F\\u002Fgithub.com\\u002Fkenkoooo\\u002FAtCoderProblems).\\nOnly AC number is supported\\n",
url: "https:\\u002F\\u002Fatcoder.jp",
name: w
},
Expand Down

0 comments on commit 31fa038

Please sign in to comment.