Skip to content

update #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## version 2.5.1

- 今日提交的分类,方便设置下次回顾时间

## version 2.4.1

- 简易 remark 功能, 用于回忆思考过程? 后续需要用这个数据生成文章
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-leetcode-problem-rating",
"displayName": "LeetCode",
"description": "LeetCode 官方插件增强, 代码开源, 增加 LeetCode 题目难度分, 给个star吧, 球球了",
"version": "2.4.1",
"version": "2.5.1",
"author": "ccagml",
"publisher": "ccagml",
"license": "MIT",
Expand Down
35 changes: 35 additions & 0 deletions src/controller/BricksViewController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,23 @@ class BricksViewController implements Disposable {
}
// 今天搬的
public async getTodayNodes() {
let all_qid: string[] = await bricksDao.getTodayBricksSubmit();
const baseNode: BricksNode[] = [];
all_qid.forEach((qid) => {
let node = treeViewController.getNodeByQid(qid);
if (node) {
baseNode.push(node);
}
});
return baseNode;
}

public async getRootNodes(): Promise<BricksNode[]> {
let all_qid: string[] = await bricksDao.getTodayBricks();
let all_submit_qid: string[] = await bricksDao.getTodayBricksSubmit();

let has_qid = all_qid.length > 0;
let has_submit = all_submit_qid.length > 0;
const baseNode: BricksNode[] = [];

baseNode.push(
Expand All @@ -55,6 +65,31 @@ class BricksViewController implements Disposable {
has_qid ? TreeItemCollapsibleState.Collapsed : TreeItemCollapsibleState.None
)
);

if (has_submit) {
let temp_score = 0;
all_submit_qid.forEach((qid) => {
let node = treeViewController.getNodeByQid(qid);
if (node && node.score && Number(node.score) > 0) {
temp_score += Number(node.score);
}
});

baseNode.push(
new BricksNode(
Object.assign({}, defaultProblem, {
id: BricksNormalId.Today,
name:
`今天搬了${all_submit_qid.length}块砖,赚了${temp_score}分` +
(all_submit_qid.length > 3 ? ",又是上分的一天~" : ",别吹牛了,赶紧干活啊!!!"),
}),
false,
0,
TreeItemCollapsibleState.Collapsed
)
);
}

return baseNode;
}

Expand Down
15 changes: 15 additions & 0 deletions src/dao/bricksDao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,21 @@ class BricksDao {
return all_qid;
}

public async getTodayBricksSubmit(): Promise<string[]> {
let today_time = getDayStart();
let all_bricks = await this.getAllBricks();
let all_qid: Array<string> = [];
for (const qid in all_bricks) {
const value = all_bricks[qid];
const submit_time = value.submit_time || [];
let submit_size = submit_time.length;
if (submit_size > 0 && submit_time[submit_size - 1] >= today_time) {
all_qid.push(qid);
}
}
return all_qid;
}

public async getInfoByQid(qid: string) {
let all_bricks = await this.getAllBricks();
return all_bricks[qid] || {};
Expand Down
1 change: 0 additions & 1 deletion src/model/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ export enum BricksNormalId {
No = "bricksNo", // 没活
NoDesc = "工头让你去上面那个工地,过几天再回来",
Today = "bricksToday",
TodayDesc = "今天搬好的砖",
}

export enum BricksType {
Expand Down