Fix tech rev rejection query (#4963)

This commit is contained in:
François-Xavier Talbot
2025-12-29 16:06:47 -05:00
committed by GitHub
parent 9f356beec3
commit 9924faab84
7 changed files with 48 additions and 118 deletions

View File

@@ -1,26 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n SELECT\n id,\n status AS \"status: PayoutStatus\"\n FROM payouts\n ORDER BY id\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Int8"
},
{
"ordinal": 1,
"name": "status: PayoutStatus",
"type_info": "Varchar"
}
],
"parameters": {
"Left": []
},
"nullable": [
false,
false
]
},
"hash": "1adbd24d815107e13bc1440c7a8f4eeff66ab4165a9f4980032e114db4dc1286"
}

View File

@@ -1,29 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n UPDATE mods\n SET status = $1\n FROM mods m\n INNER JOIN threads t ON t.mod_id = m.id\n WHERE m.id = $2\n RETURNING\n t.id AS \"thread_id: DBThreadId\",\n (SELECT status FROM mods WHERE id = m.id) AS \"old_status!\"\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "thread_id: DBThreadId",
"type_info": "Int8"
},
{
"ordinal": 1,
"name": "old_status!",
"type_info": "Varchar"
}
],
"parameters": {
"Left": [
"Varchar",
"Int8"
]
},
"nullable": [
false,
null
]
},
"hash": "3473715e4ff6efb6707f73e8ddf19ef7bcbb341c7ffea3d13acd250bb20e6d07"
}

View File

@@ -0,0 +1,29 @@
{
"db_name": "PostgreSQL",
"query": "\n WITH old AS (\n SELECT id, status\n FROM mods\n WHERE id = $2\n ),\n updated AS (\n UPDATE mods\n SET status = $1\n FROM threads t\n WHERE\n mods.id = $2\n AND t.mod_id = mods.id\n RETURNING mods.id, t.id AS thread_id\n )\n SELECT\n updated.thread_id AS \"thread_id: DBThreadId\",\n old.status AS \"old_status!\"\n FROM updated\n INNER JOIN old ON old.id = updated.id\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "thread_id: DBThreadId",
"type_info": "Int8"
},
{
"ordinal": 1,
"name": "old_status!",
"type_info": "Varchar"
}
],
"parameters": {
"Left": [
"Varchar",
"Int8"
]
},
"nullable": [
false,
false
]
},
"hash": "b2c71f0b227d11cf9d26f8c3eaf9a9f7293a8a57be522db81dcacf594ea913a4"
}

View File

@@ -1,20 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "SELECT status AS \"status: PayoutStatus\" FROM payouts WHERE id = 1",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "status: PayoutStatus",
"type_info": "Varchar"
}
],
"parameters": {
"Left": []
},
"nullable": [
false
]
},
"hash": "b92b5bb7d179c4fcdbc45600ccfd2402f52fea71e27b08e7926fcc2a9e62c0f3"
}

View File

@@ -1,18 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n INSERT INTO payouts (id, method, platform_id, status, user_id, amount, created)\n VALUES ($1, $2, $3, $4, $5, 10.0, NOW())\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8",
"Text",
"Text",
"Varchar",
"Int8"
]
},
"nullable": []
},
"hash": "cd5ccd618fb3cc41646a6de86f9afedb074492b4ec7f2457c14113f5fd13aa02"
}

View File

@@ -1,17 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n INSERT INTO payouts (id, method, platform_id, status, user_id, amount, created)\n VALUES ($1, $2, NULL, $3, $4, 10.00, NOW())\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8",
"Text",
"Varchar",
"Int8"
]
},
"nullable": []
},
"hash": "cec4240c7c848988b3dfd13e3f8e5c93783c7641b019fdb698a1ec0be1393606"
}

View File

@@ -726,14 +726,25 @@ async fn submit_report(
if verdict == DelphiVerdict::Unsafe {
let record = sqlx::query!(
r#"
UPDATE mods
SET status = $1
FROM mods m
INNER JOIN threads t ON t.mod_id = m.id
WHERE m.id = $2
RETURNING
t.id AS "thread_id: DBThreadId",
(SELECT status FROM mods WHERE id = m.id) AS "old_status!"
WITH old AS (
SELECT id, status
FROM mods
WHERE id = $2
),
updated AS (
UPDATE mods
SET status = $1
FROM threads t
WHERE
mods.id = $2
AND t.mod_id = mods.id
RETURNING mods.id, t.id AS thread_id
)
SELECT
updated.thread_id AS "thread_id: DBThreadId",
old.status AS "old_status!"
FROM updated
INNER JOIN old ON old.id = updated.id
"#,
ProjectStatus::Rejected.as_str(),
project_id as _,