feat: 增加收藏、下载种子数据功能
This commit is contained in:
@@ -5,6 +5,13 @@ cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV });
|
||||
const VALID_STATUS = new Set(['draft', 'active', 'hidden']);
|
||||
const STATUS_ORDER = { draft: 0, hidden: 1, active: 2 };
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
exports.main = async (event) => {
|
||||
try {
|
||||
const db = cloud.database();
|
||||
@@ -54,6 +61,8 @@ exports.main = async (event) => {
|
||||
else if (item.status === 'hidden') stats.hidden++;
|
||||
}
|
||||
|
||||
mergeSeedStats(data);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data,
|
||||
|
||||
Reference in New Issue
Block a user