Speed up delete query
This commit is contained in:
parent
7395685e0d
commit
dcfb5a2d4f
@ -1,6 +1,12 @@
|
|||||||
version: '3.3'
|
version: '3.3'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
bot:
|
||||||
|
build: ./Containerfile.run
|
||||||
|
image: reminder-rs-run
|
||||||
|
restart: always
|
||||||
|
expose:
|
||||||
|
- '80'
|
||||||
database:
|
database:
|
||||||
image: mysql:8.0
|
image: mysql:8.0
|
||||||
restart: always
|
restart: always
|
||||||
@ -13,4 +19,3 @@ services:
|
|||||||
- '3306'
|
- '3306'
|
||||||
volumes:
|
volumes:
|
||||||
- reminders:/var/lib/mysql
|
- reminders:/var/lib/mysql
|
||||||
|
|
||||||
|
@ -153,17 +153,17 @@ impl ComponentDataModel {
|
|||||||
ComponentDataModel::DelSelector(selector) => {
|
ComponentDataModel::DelSelector(selector) => {
|
||||||
if let ComponentInteractionDataKind::StringSelect { values } = &component.data.kind
|
if let ComponentInteractionDataKind::StringSelect { values } = &component.data.kind
|
||||||
{
|
{
|
||||||
let selected_id = values.join(",");
|
let placeholder = values.iter().map(|_| "?").collect::<Vec<&str>>().join(",");
|
||||||
|
let sql = format!(
|
||||||
|
"UPDATE reminders SET `status` = 'deleted' WHERE id IN ({placeholder})"
|
||||||
|
);
|
||||||
|
let mut query = sqlx::query(&sql);
|
||||||
|
|
||||||
sqlx::query!(
|
for id in values {
|
||||||
"
|
query = query.bind(id);
|
||||||
UPDATE reminders SET `status` = 'deleted' WHERE FIND_IN_SET(id, ?)
|
}
|
||||||
",
|
|
||||||
selected_id
|
query.execute(&data.database).await.unwrap();
|
||||||
)
|
|
||||||
.execute(&data.database)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let reminders = Reminder::from_guild(
|
let reminders = Reminder::from_guild(
|
||||||
&ctx,
|
&ctx,
|
||||||
|
Loading…
Reference in New Issue
Block a user