mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-10 18:02:55 +00:00
perf: 删除冗余字段
This commit is contained in:
parent
ebe953cf63
commit
87e46ec5a5
@ -200,7 +200,6 @@ class WebSocketDialogMsg extends AbstractModel
|
||||
'msg_id' => $this->id,
|
||||
'userid' => $userid,
|
||||
'after' => 1,
|
||||
'live' => 1,
|
||||
]);
|
||||
if ($msgRead->saveOrIgnore()) {
|
||||
$this->send = WebSocketDialogMsgRead::whereMsgId($this->id)->count();
|
||||
|
||||
@ -16,7 +16,6 @@ use Carbon\Carbon;
|
||||
* @property int|null $email 是否发了邮件
|
||||
* @property int|null $after 在阅读之后才添加的记录
|
||||
* @property int|null $dot 红点标记
|
||||
* @property int|null $live 是否在会话里
|
||||
* @property \Illuminate\Support\Carbon|null $read_at 阅读时间
|
||||
* @property-read \App\Models\WebSocketDialogMsg|null $webSocketDialogMsg
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|AbstractModel cancelAppend()
|
||||
@ -33,7 +32,6 @@ use Carbon\Carbon;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsgRead whereDot($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsgRead whereEmail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsgRead whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsgRead whereLive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsgRead whereMention($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsgRead whereMsgId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsgRead whereReadAt($value)
|
||||
|
||||
@ -4,7 +4,6 @@ namespace App\Observers;
|
||||
|
||||
use App\Models\Deleted;
|
||||
use App\Models\WebSocketDialog;
|
||||
use App\Models\WebSocketDialogMsgRead;
|
||||
use App\Models\WebSocketDialogUser;
|
||||
|
||||
class WebSocketDialogObserver
|
||||
@ -40,7 +39,6 @@ class WebSocketDialogObserver
|
||||
public function deleted(WebSocketDialog $webSocketDialog)
|
||||
{
|
||||
Deleted::record('dialog', $webSocketDialog->id, $this->userids($webSocketDialog));
|
||||
WebSocketDialogMsgRead::whereDialogId($webSocketDialog->id)->update(['live' => 0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,7 +51,6 @@ class WebSocketDialogObserver
|
||||
{
|
||||
$userids = $this->userids($webSocketDialog);
|
||||
Deleted::forget('dialog', $webSocketDialog->id, $userids);
|
||||
WebSocketDialogMsgRead::whereDialogId($webSocketDialog->id)->whereIn('userid', $userids)->update(['live' => 1]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\Deleted;
|
||||
use App\Models\WebSocketDialogMsgRead;
|
||||
use App\Models\WebSocketDialogUser;
|
||||
use Carbon\Carbon;
|
||||
|
||||
@ -30,7 +29,6 @@ class WebSocketDialogUserObserver
|
||||
}
|
||||
}
|
||||
Deleted::forget('dialog', $webSocketDialogUser->dialog_id, $webSocketDialogUser->userid);
|
||||
WebSocketDialogMsgRead::whereDialogId($webSocketDialogUser->dialog_id)->whereUserid($webSocketDialogUser->userid)->update(['live' => 1]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,7 +51,6 @@ class WebSocketDialogUserObserver
|
||||
public function deleted(WebSocketDialogUser $webSocketDialogUser)
|
||||
{
|
||||
Deleted::record('dialog', $webSocketDialogUser->dialog_id, $webSocketDialogUser->userid);
|
||||
WebSocketDialogMsgRead::whereDialogId($webSocketDialogUser->dialog_id)->whereUserid($webSocketDialogUser->userid)->update(['live' => 0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -128,7 +128,6 @@ class WebSocketDialogMsgTask extends AbstractTask
|
||||
'mention' => $mention,
|
||||
'silence' => $silence,
|
||||
'dot' => $dot,
|
||||
'live' => 1,
|
||||
])->saveOrIgnore();
|
||||
$array[$userid] = [
|
||||
'userid' => $userid,
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use App\Models\WebSocketDialog;
|
||||
use App\Models\WebSocketDialogMsg;
|
||||
use App\Models\WebSocketDialogMsgRead;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class RemoveWebSocketDialogMsgReadsLive extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('web_socket_dialog_msg_reads', function (Blueprint $table) use (&$isAdd) {
|
||||
if (Schema::hasColumn('web_socket_dialog_msg_reads', 'live')) {
|
||||
$table->dropIndex(['userid', 'live', 'msg_id']);
|
||||
$table->dropColumn('live');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user