|
@@ -129,21 +129,23 @@ async function run() {
|
|
|
const newTotalDoneCount = (currentArt.totalDoneCount || 0) + doneRateDoc.doneCount;
|
|
const newTotalDoneCount = (currentArt.totalDoneCount || 0) + doneRateDoc.doneCount;
|
|
|
// 重新计算总完成率
|
|
// 重新计算总完成率
|
|
|
const newCompletionRate = newTotalStartCount > 0 ? (newTotalDoneCount / newTotalStartCount) * 100 : 0;
|
|
const newCompletionRate = newTotalStartCount > 0 ? (newTotalDoneCount / newTotalStartCount) * 100 : 0;
|
|
|
- // **【新增】** 更新本地 Art 文档
|
|
|
|
|
- // 不更新本地art了
|
|
|
|
|
- // await artService.updateArt(artworkId.toString(), {
|
|
|
|
|
- // totalStartCount: newTotalStartCount,
|
|
|
|
|
- // totalDoneCount: newTotalDoneCount,
|
|
|
|
|
- // completionRate: newCompletionRate,
|
|
|
|
|
- // });
|
|
|
|
|
- // updatedLocalArtworksCount++;
|
|
|
|
|
- // **【新增】** 同步更新远程 Art 文档
|
|
|
|
|
- const remoteArtDoc = await RemoteArt.findById(artworkId);
|
|
|
|
|
- if (remoteArtDoc) {
|
|
|
|
|
- remoteArtDoc.totalStartCount = newTotalStartCount;
|
|
|
|
|
- remoteArtDoc.totalDoneCount = newTotalDoneCount;
|
|
|
|
|
- remoteArtDoc.completionRate = newCompletionRate;
|
|
|
|
|
- await remoteArtDoc.save();
|
|
|
|
|
|
|
+ // 更新本地 Art 文档
|
|
|
|
|
+ await artService_1.default.updateArt(artworkId.toString(), {
|
|
|
|
|
+ totalStartCount: newTotalStartCount,
|
|
|
|
|
+ totalDoneCount: newTotalDoneCount,
|
|
|
|
|
+ completionRate: newCompletionRate,
|
|
|
|
|
+ });
|
|
|
|
|
+ updatedLocalArtworksCount++;
|
|
|
|
|
+ // 同步更新远程 Art 文档
|
|
|
|
|
+ const remoteUpdateResult = await RemoteArt.findByIdAndUpdate(artworkId, {
|
|
|
|
|
+ $set: {
|
|
|
|
|
+ totalStartCount: newTotalStartCount,
|
|
|
|
|
+ totalDoneCount: newTotalDoneCount,
|
|
|
|
|
+ completionRate: newCompletionRate,
|
|
|
|
|
+ },
|
|
|
|
|
+ }, { new: true } // 返回更新后的文档
|
|
|
|
|
+ );
|
|
|
|
|
+ if (remoteUpdateResult) {
|
|
|
updatedRemoteArtworksCount++;
|
|
updatedRemoteArtworksCount++;
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|