|
@@ -164,17 +164,29 @@ export class MomentsService {
|
|
|
.getMany()
|
|
.getMany()
|
|
|
|
|
|
|
|
momentsList.forEach(moments => {
|
|
momentsList.forEach(moments => {
|
|
|
|
|
+
|
|
|
|
|
+ const targetTime = new Date();
|
|
|
|
|
+ targetTime.setHours(Math.floor(Math.random() * 12) + 10);
|
|
|
|
|
+ targetTime.setMinutes(Math.floor(Math.random() * 60));
|
|
|
|
|
+
|
|
|
|
|
+ const now = new Date();
|
|
|
|
|
+ const delayTime = targetTime.getTime() - now.getTime();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
const hours = Math.floor(Math.random() * 12)
|
|
const hours = Math.floor(Math.random() * 12)
|
|
|
const minutes = Math.floor(Math.random() * 60)
|
|
const minutes = Math.floor(Math.random() * 60)
|
|
|
console.log(moments.userId + '的动态将在' + hours + '小时' + minutes + '分后发布')
|
|
console.log(moments.userId + '的动态将在' + hours + '小时' + minutes + '分后发布')
|
|
|
- setTimeout(async () => {
|
|
|
|
|
- moments.isPush = true
|
|
|
|
|
- moments.createdAt = new Date()
|
|
|
|
|
- await this.momentsRepository.save(moments)
|
|
|
|
|
- const chatRole = await this.chatRoleRepository.findOneBy({ id: moments.userId })
|
|
|
|
|
- chatRole.dynamicNumber += 1
|
|
|
|
|
- await this.chatRoleRepository.save(chatRole)
|
|
|
|
|
- }, hours * 60 * 60 * 1000 + minutes * 60 * 1000)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (delayTime > 0) {
|
|
|
|
|
+ setTimeout(async () => {
|
|
|
|
|
+ moments.isPush = true
|
|
|
|
|
+ moments.createdAt = new Date()
|
|
|
|
|
+ await this.momentsRepository.save(moments)
|
|
|
|
|
+ const chatRole = await this.chatRoleRepository.findOneBy({ id: moments.userId })
|
|
|
|
|
+ chatRole.dynamicNumber += 1
|
|
|
|
|
+ await this.chatRoleRepository.save(chatRole)
|
|
|
|
|
+ }, delayTime)
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|