perf: 重写更新和删除方法

This commit is contained in:
kuaifan 2023-03-07 20:13:50 +08:00
parent bca28fb390
commit 31c1466b42
4 changed files with 8 additions and 8 deletions

View File

@ -211,7 +211,7 @@ class Project extends AbstractModel
'important' => 1
]);
}
WebSocketDialogUser::whereDialogId($this->dialog_id)->whereNotIn('userid', $userids)->whereImportant(1)->delete();
WebSocketDialogUser::whereDialogId($this->dialog_id)->whereNotIn('userid', $userids)->whereImportant(1)->remove();
});
}
@ -252,7 +252,7 @@ class Project extends AbstractModel
$this->archived_userid = User::userid();
$this->addLog("项目取消归档");
$this->pushMsg('recovery', $this);
ProjectTask::whereProjectId($this->id)->whereArchivedFollow(1)->update([
ProjectTask::whereProjectId($this->id)->whereArchivedFollow(1)->modify([
'archived_at' => null,
'archived_follow' => 0
]);
@ -262,7 +262,7 @@ class Project extends AbstractModel
$this->archived_userid = User::userid();
$this->addLog("项目归档");
$this->pushMsg('archived');
ProjectTask::whereProjectId($this->id)->whereArchivedAt(null)->update([
ProjectTask::whereProjectId($this->id)->whereArchivedAt(null)->modify([
'archived_at' => $archived_at,
'archived_follow' => 1
]);

View File

@ -1047,7 +1047,7 @@ class ProjectTask extends AbstractModel
'important' => 1
]);
}
WebSocketDialogUser::whereDialogId($this->dialog_id)->whereNotIn('userid', $userids)->whereImportant(1)->delete();
WebSocketDialogUser::whereDialogId($this->dialog_id)->whereNotIn('userid', $userids)->whereImportant(1)->remove();
});
}
@ -1265,7 +1265,7 @@ class ProjectTask extends AbstractModel
'archived_at' => $this->archived_at,
'archived_userid' => $this->archived_userid,
]);
self::whereParentId($this->id)->update([
self::whereParentId($this->id)->modify([
'archived_at' => $this->archived_at,
'archived_userid' => $this->archived_userid,
'archived_follow' => $this->archived_follow,
@ -1287,7 +1287,7 @@ class ProjectTask extends AbstractModel
$dialog = WebSocketDialog::find($this->dialog_id);
$dialog?->deleteDialog();
}
self::whereParentId($this->id)->delete();
self::whereParentId($this->id)->remove();
$this->deleted_userid = User::userid();
$this->save();
$this->addLog("删除{任务}");

View File

@ -27,7 +27,7 @@ class ProjectTasksAddArchivedFollow extends Migration
// 更新数据
Project::whereNotNull('archived_at')->chunkById(100, function ($lists) {
foreach ($lists as $item) {
ProjectTask::whereProjectId($item->id)->whereArchivedAt(null)->update([
ProjectTask::whereProjectId($item->id)->whereArchivedAt(null)->modify([
'archived_at' => $item->archived_at,
'archived_follow' => 1
]);

View File

@ -18,7 +18,7 @@ class ProjectTasksUpdateSubtaskArchivedDelete extends Migration
->chunkById(100, function ($lists) {
/** @var ProjectTask $task */
foreach ($lists as $task) {
ProjectTask::whereParentId($task->id)->update([
ProjectTask::whereParentId($task->id)->modify([
'archived_at' => $task->archived_at,
'archived_userid' => $task->archived_userid,
'archived_follow' => $task->archived_follow,