File tree Expand file tree Collapse file tree 2 files changed +37784
-5
lines changed Expand file tree Collapse file tree 2 files changed +37784
-5
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ const mySolutions = require("../static/my/solutions.json");
9
9
const meta = require ( "../static/meta.json" ) ;
10
10
11
11
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
+
12
16
function getAllPages ( i , issue_number ) {
13
17
return octokit . rest . issues
14
18
. listComments ( {
@@ -39,12 +43,15 @@ async function run(d) {
39
43
}
40
44
// 由于下面的一行代码,导致了会插入一个完全空的行。这就是因为打过卡,但是都不是当天打的
41
45
if ( comment . body . length < 20 ) return ;
46
+ if ( mySolutions [ login ] [ d - 1 ] . onTime !== void 0 ) return ; // 如果打卡过或者补卡过就不同步了
42
47
// 由于索引从 1 开始,因此需要再减去 1。
43
48
mySolutions [ login ] [ d - 1 ] = {
44
49
// title: problem.title,
45
50
url : comment . html_url ,
46
51
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 , // 有可能早出题,防止早打卡的人没被统计进去,所以用 <= 。
48
55
} ;
49
56
} ) ;
50
57
meta . dailyCheck . lastUpdateTime = new Date ( ) . getTime ( ) ;
@@ -61,9 +68,6 @@ async function run(d) {
61
68
}
62
69
}
63
70
64
- const MS_PER_HOUR = 1 * 60 * 60 * 1000 ;
65
- const TODAY = getDay ( new Date ( ) . getTime ( ) - MS_PER_HOUR ) ; // 获取今天‘的题目。 为了照顾一些人, 我们凌晨一点统计昨天的,而不是当天的。
66
-
67
71
// 仅更新当天的
68
72
if ( getDay ( TODAY ) - getDay ( meta . dailyCheck . lastUpdateTime ) < 1 ) {
69
73
run ( TODAY ) ;
Load Diff Large diffs are not rendered by default.
You can’t perform that action at this time.
0 commit comments