Skip to content
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

[feature request] 优化作业页面排序 #148

Closed
HustreLiny opened this issue Oct 20, 2023 · 2 comments
Closed

[feature request] 优化作业页面排序 #148

HustreLiny opened this issue Oct 20, 2023 · 2 comments
Assignees

Comments

@HustreLiny
Copy link

希望能把未完成作业排在“所有作业”的最前面
按DDL剩余时间排序导致前面都是已完成的作业,十分迷惑。

@Harry-Chen
Copy link
Owner

根据排序逻辑,的确是这样的:

.sort((a, b) => {
const aNotDue =
a.type === ContentType.HOMEWORK && a.date.getTime() > new Date().getTime();
const bNotDue =
b.type === ContentType.HOMEWORK && b.date.getTime() > new Date().getTime();
return (
compareBoolean(a.starred, b.starred) ||
compareBoolean(!a.hasRead, !b.hasRead) ||
compareBoolean(aNotDue, bNotDue) ||
(a.date.getTime() - b.date.getTime()) * (aNotDue && bNotDue ? 1 : -1)
);
})
.map(({ type, id }) => ({ type, id })),
),
);

@AsakuraMizu 看一下为何不符合预期?

@AsakuraMizu
Copy link
Collaborator

根据排序逻辑,的确是这样的:

.sort((a, b) => {
const aNotDue =
a.type === ContentType.HOMEWORK && a.date.getTime() > new Date().getTime();
const bNotDue =
b.type === ContentType.HOMEWORK && b.date.getTime() > new Date().getTime();
return (
compareBoolean(a.starred, b.starred) ||
compareBoolean(!a.hasRead, !b.hasRead) ||
compareBoolean(aNotDue, bNotDue) ||
(a.date.getTime() - b.date.getTime()) * (aNotDue && bNotDue ? 1 : -1)
);
})
.map(({ type, id }) => ({ type, id })),
),
);

@AsakuraMizu 看一下为何不符合预期?

他的意思是加一个按作业的 submitted 排序。祖传下来的排序逻辑并没有考虑这个

@AsakuraMizu AsakuraMizu changed the title 优化作业页面排序 [feature request] 优化作业页面排序 Oct 21, 2023
@AsakuraMizu AsakuraMizu self-assigned this Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants