Fix todo list deletion not working properly
This commit is contained in:
parent
c277f85c2a
commit
ef10902c1e
@ -282,13 +282,43 @@ impl ComponentDataModel {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let values = sqlx::query!(
|
||||
// fucking braindead mysql use <=> instead of = for null comparison
|
||||
let values = if let Some(uid) = selector.user_id {
|
||||
sqlx::query!(
|
||||
"
|
||||
SELECT id, value FROM todos WHERE user_id <=> ? AND channel_id <=> ? AND guild_id <=> ?
|
||||
SELECT todos.id, value FROM todos
|
||||
INNER JOIN users ON todos.user_id = users.id
|
||||
WHERE users.user = ?
|
||||
",
|
||||
uid,
|
||||
)
|
||||
.fetch_all(&data.database)
|
||||
.await
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(|row| (row.id as usize, row.value.clone()))
|
||||
.collect::<Vec<(usize, String)>>()
|
||||
} else if let Some(cid) = selector.channel_id {
|
||||
sqlx::query!(
|
||||
"
|
||||
SELECT todos.id, value FROM todos
|
||||
INNER JOIN channels ON todos.channel_id = channels.id
|
||||
WHERE channels.channel = ?
|
||||
",
|
||||
cid,
|
||||
)
|
||||
.fetch_all(&data.database)
|
||||
.await
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(|row| (row.id as usize, row.value.clone()))
|
||||
.collect::<Vec<(usize, String)>>()
|
||||
} else {
|
||||
sqlx::query!(
|
||||
"
|
||||
SELECT todos.id, value FROM todos
|
||||
INNER JOIN guilds ON todos.guild_id = guilds.id
|
||||
WHERE guilds.guild = ?
|
||||
",
|
||||
selector.user_id,
|
||||
selector.channel_id,
|
||||
selector.guild_id,
|
||||
)
|
||||
.fetch_all(&data.database)
|
||||
@ -296,7 +326,8 @@ impl ComponentDataModel {
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(|row| (row.id as usize, row.value.clone()))
|
||||
.collect::<Vec<(usize, String)>>();
|
||||
.collect::<Vec<(usize, String)>>()
|
||||
};
|
||||
|
||||
let resp = show_todo_page(
|
||||
&values,
|
||||
|
Loading…
Reference in New Issue
Block a user