feat: 增加收藏、下载种子数据功能
This commit is contained in:
@@ -35,6 +35,13 @@ function difficultyLabel(difficulty) {
|
||||
return DIFFICULTY_LABELS[difficulty] || '基础';
|
||||
}
|
||||
|
||||
function mergeSeedStats(items) {
|
||||
for (const item of items) {
|
||||
item.likes = (item.likes || 0) + (item.likes_seed || 0);
|
||||
item.downloads = (item.downloads || 0) + (item.downloads_seed || 0);
|
||||
}
|
||||
}
|
||||
|
||||
function toRecommendedItem(ws) {
|
||||
return {
|
||||
worksheetId: ws._id,
|
||||
@@ -118,6 +125,7 @@ exports.main = async (event) => {
|
||||
const band = AGE_BANDS[ageKey];
|
||||
const db = cloud.database();
|
||||
const activeWorksheets = await queryActiveWorksheets(db);
|
||||
mergeSeedStats(activeWorksheets);
|
||||
const matchedWorksheets = activeWorksheets.filter((ws) =>
|
||||
coversAgeBand(ws, band),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user