Skip to content

Commit 9dd659a

Browse files
author
robot
committed
fix: user 数据
1 parent 8c28fce commit 9dd659a

File tree

4 files changed

+12849
-8
lines changed

4 files changed

+12849
-8
lines changed

routes/dailyProblem.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const { startTime } = require("../config/index");
99

1010
const A = [];
1111
for (const [login, solution] of Object.entries(mySolutions)) {
12+
console.log(login);
1213
const { bio, name, noCheck, allCheck, avatar_url, card } = users[login];
1314
A.push({
1415
count: solution.filter(Boolean).length,

routes/my.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ router.get("/api/v1/my/solutions", async (ctx) => {
1111
solutions[ctx.session.user.login]
1212
.map((q, i) => ({
1313
...q,
14+
body: void 0,
1415
title: (officialSolution[i + 1] || {}).title || "",
1516
tags: (officialSolution[i + 1] || {}).tags || [],
1617
difficulty: (officialSolution[i + 1] || {}).difficulty || "",

static/users/generate.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
const fs = require("fs");
2+
const path = require("path");
23
const { Octokit } = require("@octokit/rest");
34
const { db } = require("../../config/index");
45
const users = require("./index.json");
5-
const { getDay } = require("../../utils/day");
6+
// const { getDay } = require("../../utils/day");
67
const meta = require("../meta.json");
78

89
async function run(incremental = true) {
@@ -15,7 +16,7 @@ async function run(incremental = true) {
1516
.getByUsername({ username: name })
1617
.then((res) => res.data)
1718
.then((user) => {
18-
if (incremental && !(name in users)) {
19+
if (!(name in users)) {
1920
users[name] = {
2021
...user,
2122
createTime: new Date().getTime(),
@@ -29,18 +30,24 @@ async function run(incremental = true) {
2930
};
3031
}
3132
})
32-
.catch(() => console.log(`name ${name} is invalid`))
33+
.catch((err) =>
34+
console.log(
35+
`name ${name} is invalid. detail: ${
36+
err && err.message ? err.message : err
37+
}`
38+
)
39+
)
3340
);
3441
}
3542

3643
return Promise.all(ps);
3744
}
3845
let incremental = true;
3946

40-
// 七天全量更新一次
41-
if (getDay() - getDay(meta.users.lastUpdateTime) >= 7) {
42-
incremental = false;
43-
}
47+
// // 七天全量更新一次
48+
// if (getDay() - getDay(meta.users.lastUpdateTime) >= 7) {
49+
// incremental = false;
50+
// }
4451
run(incremental).then(() => {
4552
fs.writeFileSync(__dirname + "/index.json", JSON.stringify(users));
4653
fs.writeFileSync(

static/users/index.json

Lines changed: 12833 additions & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)