Skip to content

Commit 0efd3b2

Browse files
author
robot
committed
fix: onTime
1 parent 58cce70 commit 0efd3b2

File tree

2 files changed

+37784
-5
lines changed

2 files changed

+37784
-5
lines changed

schedule/daily-check.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ const mySolutions = require("../static/my/solutions.json");
99
const meta = require("../static/meta.json");
1010

1111
const octokit = new Octokit({ auth: process.env.issueToken });
12+
13+
const MS_PER_HOUR = 1 * 60 * 60 * 1000;
14+
const TODAY = getDay(new Date().getTime() - MS_PER_HOUR); // 获取今天‘的题目。 为了照顾一些人, 我们凌晨一点统计昨天的,而不是当天的。
15+
1216
function getAllPages(i, issue_number) {
1317
return octokit.rest.issues
1418
.listComments({
@@ -39,12 +43,15 @@ async function run(d) {
3943
}
4044
// 由于下面的一行代码,导致了会插入一个完全空的行。这就是因为打过卡,但是都不是当天打的
4145
if (comment.body.length < 20) return;
46+
if (mySolutions[login][d - 1].onTime !== void 0) return; // 如果打卡过或者补卡过就不同步了
4247
// 由于索引从 1 开始,因此需要再减去 1。
4348
mySolutions[login][d - 1] = {
4449
// title: problem.title,
4550
url: comment.html_url,
4651
body: comment.body,
47-
onTime: getDay(new Date(comment.created_at).getTime()) <= d,
52+
// 只有当天的才标记为 onTime。防止创建一个空白的 comment,之后再编辑
53+
onTime:
54+
TODAY === d && getDay(new Date(comment.created_at).getTime()) <= d, // 有可能早出题,防止早打卡的人没被统计进去,所以用 <= 。
4855
};
4956
});
5057
meta.dailyCheck.lastUpdateTime = new Date().getTime();
@@ -61,9 +68,6 @@ async function run(d) {
6168
}
6269
}
6370

64-
const MS_PER_HOUR = 1 * 60 * 60 * 1000;
65-
const TODAY = getDay(new Date().getTime() - MS_PER_HOUR); // 获取今天‘的题目。 为了照顾一些人, 我们凌晨一点统计昨天的,而不是当天的。
66-
6771
// 仅更新当天的
6872
if (getDay(TODAY) - getDay(meta.dailyCheck.lastUpdateTime) < 1) {
6973
run(TODAY);

static/my/solutions.json

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

0 commit comments

Comments
 (0)