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