Skip to content

Commit 9413862

Browse files
authored
Merge pull request #68 from ccagml/main
update
2 parents a9e799b + a9bac19 commit 9413862

File tree

5 files changed

+55
-2
lines changed

5 files changed

+55
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## version 2.5.1
2+
3+
- 今日提交的分类,方便设置下次回顾时间
4+
15
## version 2.4.1
26

37
- 简易 remark 功能, 用于回忆思考过程? 后续需要用这个数据生成文章

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-leetcode-problem-rating",
33
"displayName": "LeetCode",
44
"description": "LeetCode 官方插件增强, 代码开源, 增加 LeetCode 题目难度分, 给个star吧, 球球了",
5-
"version": "2.4.1",
5+
"version": "2.5.1",
66
"author": "ccagml",
77
"publisher": "ccagml",
88
"license": "MIT",

src/controller/BricksViewController.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,23 @@ class BricksViewController implements Disposable {
3535
}
3636
// 今天搬的
3737
public async getTodayNodes() {
38+
let all_qid: string[] = await bricksDao.getTodayBricksSubmit();
3839
const baseNode: BricksNode[] = [];
40+
all_qid.forEach((qid) => {
41+
let node = treeViewController.getNodeByQid(qid);
42+
if (node) {
43+
baseNode.push(node);
44+
}
45+
});
3946
return baseNode;
4047
}
4148

4249
public async getRootNodes(): Promise<BricksNode[]> {
4350
let all_qid: string[] = await bricksDao.getTodayBricks();
51+
let all_submit_qid: string[] = await bricksDao.getTodayBricksSubmit();
52+
4453
let has_qid = all_qid.length > 0;
54+
let has_submit = all_submit_qid.length > 0;
4555
const baseNode: BricksNode[] = [];
4656

4757
baseNode.push(
@@ -55,6 +65,31 @@ class BricksViewController implements Disposable {
5565
has_qid ? TreeItemCollapsibleState.Collapsed : TreeItemCollapsibleState.None
5666
)
5767
);
68+
69+
if (has_submit) {
70+
let temp_score = 0;
71+
all_submit_qid.forEach((qid) => {
72+
let node = treeViewController.getNodeByQid(qid);
73+
if (node && node.score && Number(node.score) > 0) {
74+
temp_score += Number(node.score);
75+
}
76+
});
77+
78+
baseNode.push(
79+
new BricksNode(
80+
Object.assign({}, defaultProblem, {
81+
id: BricksNormalId.Today,
82+
name:
83+
`今天搬了${all_submit_qid.length}块砖,赚了${temp_score}分` +
84+
(all_submit_qid.length > 3 ? ",又是上分的一天~" : ",别吹牛了,赶紧干活啊!!!"),
85+
}),
86+
false,
87+
0,
88+
TreeItemCollapsibleState.Collapsed
89+
)
90+
);
91+
}
92+
5893
return baseNode;
5994
}
6095

src/dao/bricksDao.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,21 @@ class BricksDao {
128128
return all_qid;
129129
}
130130

131+
public async getTodayBricksSubmit(): Promise<string[]> {
132+
let today_time = getDayStart();
133+
let all_bricks = await this.getAllBricks();
134+
let all_qid: Array<string> = [];
135+
for (const qid in all_bricks) {
136+
const value = all_bricks[qid];
137+
const submit_time = value.submit_time || [];
138+
let submit_size = submit_time.length;
139+
if (submit_size > 0 && submit_time[submit_size - 1] >= today_time) {
140+
all_qid.push(qid);
141+
}
142+
}
143+
return all_qid;
144+
}
145+
131146
public async getInfoByQid(qid: string) {
132147
let all_bricks = await this.getAllBricks();
133148
return all_bricks[qid] || {};

src/model/Model.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ export enum BricksNormalId {
156156
No = "bricksNo", // 没活
157157
NoDesc = "工头让你去上面那个工地,过几天再回来",
158158
Today = "bricksToday",
159-
TodayDesc = "今天搬好的砖",
160159
}
161160

162161
export enum BricksType {

0 commit comments

Comments
 (0)