feat(VocabService, VocabCourseView): enhance SRS item retrieval and UI integration
All checks were successful
Deploy to production / deploy (push) Successful in 1m52s
All checks were successful
Deploy to production / deploy (push) Successful in 1m52s
- Updated VocabService to calculate total due count for spaced repetition system (SRS) items, improving data handling for user queries. - Modified VocabCourseView to incorporate total due count in the UI, ensuring accurate display of SRS item statistics. - Enhanced error handling and data validation for SRS due items, improving overall reliability and user experience.
This commit is contained in:
@@ -1801,14 +1801,16 @@ export default class VocabService {
|
||||
|
||||
const limit = this._clampInteger(query?.limit, { min: 1, max: 100, fallback: 30 });
|
||||
const now = new Date();
|
||||
const dueWhere = {
|
||||
userId: user.id,
|
||||
courseId: Number(course.id),
|
||||
nextDueAt: {
|
||||
[Op.lte]: now
|
||||
}
|
||||
};
|
||||
const totalDueCount = await VocabSrsItem.count({ where: dueWhere });
|
||||
const rows = await VocabSrsItem.findAll({
|
||||
where: {
|
||||
userId: user.id,
|
||||
courseId: Number(course.id),
|
||||
nextDueAt: {
|
||||
[Op.lte]: now
|
||||
}
|
||||
},
|
||||
where: dueWhere,
|
||||
order: [
|
||||
['nextDueAt', 'ASC'],
|
||||
['wrongCount', 'DESC'],
|
||||
@@ -1821,6 +1823,8 @@ export default class VocabService {
|
||||
courseId: course.id,
|
||||
dueAt: now.toISOString(),
|
||||
count: rows.length,
|
||||
totalDueCount,
|
||||
limit,
|
||||
items: rows.map((item) => ({
|
||||
itemKey: item.itemKey,
|
||||
courseId: item.courseId,
|
||||
|
||||
Reference in New Issue
Block a user