Simplify query! string literals

This commit is contained in:
Joscha 2024-05-13 16:14:27 +02:00
parent 7d80ba4a6b
commit 7a6984aedc
36 changed files with 312 additions and 312 deletions

View file

@ -0,0 +1,12 @@
{
"db_name": "SQLite",
"query": "\n INSERT INTO run_output (\n id,\n line,\n source,\n text\n )\n VALUES (?, ?, ?, ?)\n ",
"describe": {
"columns": [],
"parameters": {
"Right": 4
},
"nullable": []
},
"hash": "09c34c5cef41d9833c345c8447d35a975a4b76dd2c7b3ad169674e3a6acf6862"
}

View file

@ -0,0 +1,12 @@
{
"db_name": "SQLite",
"query": "\n INSERT OR IGNORE INTO queue (hash, date, priority)\n SELECT hash, ?, ?\n FROM commits\n LEFT JOIN runs USING (hash)\n WHERE reachable = ? AND id IS NULL\n ORDER BY unixepoch(committer_date) DESC\n LIMIT ?\n ",
"describe": {
"columns": [],
"parameters": {
"Right": 4
},
"nullable": []
},
"hash": "11b41ecfe4b4eae5f36d1c033f831220f9103168bfdce0fa3a676b0ec12b9d11"
}

View file

@ -1,6 +1,6 @@
{ {
"db_name": "SQLite", "db_name": "SQLite",
"query": "SELECT source, text FROM run_output WHERE id = ? ORDER BY line ASC ", "query": "\n SELECT source, text FROM run_output\n WHERE id = ?\n ORDER BY line ASC\n ",
"describe": { "describe": {
"columns": [ "columns": [
{ {
@ -22,5 +22,5 @@
false false
] ]
}, },
"hash": "bf7e8565a6ddea9d894fbeef3c9e7ed5e71893b920f5f36e80a5e2ed65cc9bb9" "hash": "14dc7ea3da2200eddf0e9087594180f71c52d2107823066681e29bc2711e911f"
} }

View file

@ -1,12 +0,0 @@
{
"db_name": "SQLite",
"query": "INSERT OR IGNORE INTO queue (hash, date, priority) SELECT hash, ?, ? FROM commits LEFT JOIN runs USING (hash) WHERE reachable = ? AND id IS NULL ORDER BY unixepoch(committer_date) DESC LIMIT ? ",
"describe": {
"columns": [],
"parameters": {
"Right": 4
},
"nullable": []
},
"hash": "1b572ecd6904a13d78070bc6aeef3a4f349baa5b880aaa1d141b516a34517b4b"
}

View file

@ -0,0 +1,12 @@
{
"db_name": "SQLite",
"query": "\n INSERT INTO queue (hash, date, priority) VALUES (?, ?, ?)\n ON CONFLICT (hash) DO UPDATE\n SET priority = excluded.priority WHERE priority < excluded.priority\n ",
"describe": {
"columns": [],
"parameters": {
"Right": 3
},
"nullable": []
},
"hash": "1d1807ce05adb453b5cfef85cff930e974faa9455e7114a1555d78f2d1911898"
}

View file

@ -0,0 +1,12 @@
{
"db_name": "SQLite",
"query": "\n INSERT INTO run_measurements (\n id,\n metric,\n value,\n unit\n )\n VALUES (?, ?, ?, ?)\n ",
"describe": {
"columns": [],
"parameters": {
"Right": 4
},
"nullable": []
},
"hash": "25e9bf1ca16d2ad13900bfbc8908531139b00e341dfa392a9d5136bc180559ac"
}

View file

@ -1,12 +0,0 @@
{
"db_name": "SQLite",
"query": "INSERT INTO refs (name, hash) VALUES (?, ?) ON CONFLICT (name) DO UPDATE SET hash = excluded.hash ",
"describe": {
"columns": [],
"parameters": {
"Right": 2
},
"nullable": []
},
"hash": "3204ae1d17471bf90a056119f164dd4f42670801bd647fb962f0ba8de37b050e"
}

View file

@ -1,6 +1,6 @@
{ {
"db_name": "SQLite", "db_name": "SQLite",
"query": "SELECT metric, value, unit FROM run_measurements WHERE id = ? ORDER BY metric ASC ", "query": "\n SELECT\n metric,\n value,\n unit\n FROM run_measurements\n WHERE id = ?\n ORDER BY metric ASC\n ",
"describe": { "describe": {
"columns": [ "columns": [
{ {
@ -28,5 +28,5 @@
true true
] ]
}, },
"hash": "185c3516e116876f1783f25ffeb179ca6ecb4f9a001a48127516a81b7a50062a" "hash": "37d23c0a75a66e41fbdc1f26e166a03a685532e5193b0c0ea330157b4334ab4e"
} }

View file

@ -0,0 +1,12 @@
{
"db_name": "SQLite",
"query": "\n INSERT OR IGNORE INTO commits (\n hash,\n author,\n author_date,\n committer,\n committer_date,\n message\n )\n VALUES (?, ?, ?, ?, ?, ?)\n ",
"describe": {
"columns": [],
"parameters": {
"Right": 6
},
"nullable": []
},
"hash": "4b91b7c764b114b401bfe3bff116fc82b21181217463211eec79f92bdc31d687"
}

View file

@ -1,6 +1,6 @@
{ {
"db_name": "SQLite", "db_name": "SQLite",
"query": "SELECT child, parent FROM commit_edges JOIN commits ON hash = child WHERE reachable = ? ORDER BY hash ASC ", "query": "\n SELECT child, parent\n FROM commit_edges\n JOIN commits ON hash = child\n WHERE reachable = ?\n ORDER BY hash ASC\n ",
"describe": { "describe": {
"columns": [ "columns": [
{ {
@ -22,5 +22,5 @@
false false
] ]
}, },
"hash": "ba09c191e2a83d4398b26888f041c93095ba82693b0b9c2c2eebd65078f7d168" "hash": "7520b53b64047c62443d415bdf37b875dc4f75a4c953f82aa72c1e42de53e8d2"
} }

View file

@ -1,12 +0,0 @@
{
"db_name": "SQLite",
"query": "WITH RECURSIVE tracked (hash) AS ( SELECT hash FROM refs WHERE tracked UNION SELECT parent FROM commit_edges JOIN tracked ON hash = child ), reachable (hash) AS ( SELECT hash FROM refs UNION SELECT hash FROM tracked UNION SELECT parent FROM commit_edges JOIN reachable ON hash = child ) UPDATE commits SET reachable = CASE WHEN hash IN tracked THEN ? WHEN hash IN reachable THEN ? ELSE ? END ",
"describe": {
"columns": [],
"parameters": {
"Right": 3
},
"nullable": []
},
"hash": "7808509e5f7d1c7e8138ff9e124ab3b1784a05ac771778ff8e503ae20d319c08"
}

View file

@ -1,12 +0,0 @@
{
"db_name": "SQLite",
"query": "INSERT INTO runs ( id, hash, bench_method, worker_name, worker_info, start, end, exit_code ) VALUES (?, ?, ?, ?, ?, ?, ?, ?) ",
"describe": {
"columns": [],
"parameters": {
"Right": 8
},
"nullable": []
},
"hash": "7af4a1edc6f7cf718fee6562c8c6fb5eaa63a4965082f3c54390ee71e4dd3a15"
}

View file

@ -1,6 +1,6 @@
{ {
"db_name": "SQLite", "db_name": "SQLite",
"query": "SELECT hash, author, message, committer_date AS \"committer_date: OffsetDateTime\" FROM commits WHERE reachable = ? ORDER BY hash ASC ", "query": "\n SELECT\n hash,\n author,\n message,\n committer_date AS \"committer_date: OffsetDateTime\"\n FROM commits\n WHERE reachable = ?\n ORDER BY hash ASC\n ",
"describe": { "describe": {
"columns": [ "columns": [
{ {
@ -34,5 +34,5 @@
false false
] ]
}, },
"hash": "2d4ddb045e286955334793d7610f1f1ee1d7d825031b003db6117231a16d2f50" "hash": "7bdc8131149c3ea2a905e9eba48afaf0ee56f280456879c34b7b1528fd9c8024"
} }

View file

@ -1,6 +1,6 @@
{ {
"db_name": "SQLite", "db_name": "SQLite",
"query": "SELECT id, start AS \"start: time::OffsetDateTime\" FROM runs WHERE hash = ? ", "query": "\n SELECT\n id,\n start AS \"start: time::OffsetDateTime\"\n FROM runs WHERE hash = ?\n ",
"describe": { "describe": {
"columns": [ "columns": [
{ {
@ -22,5 +22,5 @@
false false
] ]
}, },
"hash": "b43ea10c6fd75dfe251c3dc3001649a13b9893722b23c2bbcec1f015e57b5613" "hash": "808b4cccd8740d62cf860782be780a54e5724c38ce415f852e36e2607e3266f2"
} }

View file

@ -1,6 +1,6 @@
{ {
"db_name": "SQLite", "db_name": "SQLite",
"query": "SELECT name, hash, message, reachable AS \"reachable: Reachable\", tracked FROM refs JOIN commits USING (hash) ORDER BY name ASC ", "query": "\n SELECT\n name,\n hash,\n message,\n reachable AS \"reachable: Reachable\",\n tracked\n FROM refs\n JOIN commits USING (hash)\n ORDER BY name ASC\n ",
"describe": { "describe": {
"columns": [ "columns": [
{ {
@ -40,5 +40,5 @@
false false
] ]
}, },
"hash": "1df8ec0b41dbafe191f6990d6be6f6f3c9d86ea9ca8112f16b5735b1193ea243" "hash": "8e1df6095d9c9778e02331e1e1b332ab5fb111c1fc32c5e2f2d6d068b38ff98b"
} }

View file

@ -1,12 +0,0 @@
{
"db_name": "SQLite",
"query": "INSERT INTO run_measurements ( id, metric, value, unit ) VALUES (?, ?, ?, ?) ",
"describe": {
"columns": [],
"parameters": {
"Right": 4
},
"nullable": []
},
"hash": "8fa4d1546e559bca47e2fb765ee33b989271492395b43c1887db7d490d9dff8d"
}

View file

@ -1,6 +1,6 @@
{ {
"db_name": "SQLite", "db_name": "SQLite",
"query": "SELECT hash, author, author_date AS \"author_date: time::OffsetDateTime\", committer, committer_date AS \"committer_date: time::OffsetDateTime\", message, reachable AS \"reachable: Reachable\" FROM commits WHERE hash = ? ", "query": "\n SELECT\n hash,\n author,\n author_date AS \"author_date: time::OffsetDateTime\",\n committer,\n committer_date AS \"committer_date: time::OffsetDateTime\",\n message,\n reachable AS \"reachable: Reachable\"\n FROM commits\n WHERE hash = ?\n ",
"describe": { "describe": {
"columns": [ "columns": [
{ {
@ -52,5 +52,5 @@
false false
] ]
}, },
"hash": "c75001269238285e4de8d609a404b7249df61711324b3cae4c21b74b0875100d" "hash": "9ffcba9ec91ee686072b0c06b59d6bbcb59e36c51141ca5ea57ea69c21ba119b"
} }

View file

@ -1,12 +0,0 @@
{
"db_name": "SQLite",
"query": "INSERT INTO queue (hash, date, priority) VALUES (?, ?, ?) ON CONFLICT (hash) DO UPDATE SET priority = excluded.priority WHERE priority < excluded.priority ",
"describe": {
"columns": [],
"parameters": {
"Right": 3
},
"nullable": []
},
"hash": "aaf84d58ad3670609cf7cb28243a242829f0b5a65e39e98070664533621bc4c2"
}

View file

@ -1,6 +1,6 @@
{ {
"db_name": "SQLite", "db_name": "SQLite",
"query": "SELECT hash, message, reachable AS \"reachable: Reachable\", date AS \"date: time::OffsetDateTime\", priority FROM queue JOIN commits USING (hash) ORDER BY priority DESC, unixepoch(date) DESC, hash ASC ", "query": "\n SELECT\n hash,\n message,\n reachable AS \"reachable: Reachable\",\n date AS \"date: time::OffsetDateTime\",\n priority\n FROM queue\n JOIN commits USING (hash)\n ORDER BY priority DESC, unixepoch(date) DESC, hash ASC\n ",
"describe": { "describe": {
"columns": [ "columns": [
{ {
@ -40,5 +40,5 @@
false false
] ]
}, },
"hash": "5da81c9c9875bf4fd4e894ca54be65aee3d76a26c12feb1e4f25e9f482cd153e" "hash": "af399d06762680bbb967bd4665444a816f936e59e89b4042931de82054a2c067"
} }

View file

@ -0,0 +1,12 @@
{
"db_name": "SQLite",
"query": "\n INSERT INTO refs (name, hash) VALUES (?, ?)\n ON CONFLICT (name) DO UPDATE\n SET hash = excluded.hash\n ",
"describe": {
"columns": [],
"parameters": {
"Right": 2
},
"nullable": []
},
"hash": "b4afdd25b99339034c6c662d16119741d75776ca1a18ee7aaa5be73a2b3455e3"
}

View file

@ -1,12 +0,0 @@
{
"db_name": "SQLite",
"query": "INSERT INTO run_output ( id, line, source, text ) VALUES (?, ?, ?, ?) ",
"describe": {
"columns": [],
"parameters": {
"Right": 4
},
"nullable": []
},
"hash": "c12f5a469c6ad64bcc01f6a095f27f703dba6e519e8e218bffac81c9b8b45b95"
}

View file

@ -1,6 +1,6 @@
{ {
"db_name": "SQLite", "db_name": "SQLite",
"query": "SELECT id, hash, bench_method, start AS \"start: time::OffsetDateTime\", end AS \"end: time::OffsetDateTime\", exit_code, message, reachable AS \"reachable: Reachable\" FROM runs JOIN commits USING (hash) WHERE id = ? ", "query": "\n SELECT\n id,\n hash,\n bench_method,\n start AS \"start: time::OffsetDateTime\",\n end AS \"end: time::OffsetDateTime\",\n exit_code,\n message,\n reachable AS \"reachable: Reachable\"\n FROM runs\n JOIN commits USING (hash)\n WHERE id = ?\n ",
"describe": { "describe": {
"columns": [ "columns": [
{ {
@ -58,5 +58,5 @@
false false
] ]
}, },
"hash": "daae5a05af0e8a511f5099820da2ccbeebb577935786fdb1a235d0315bc5a433" "hash": "c1db3ac0f29ccf740eb4a798f00d6e2ecba3aa0239462e71dc8d23e405378ed0"
} }

View file

@ -1,6 +1,6 @@
{ {
"db_name": "SQLite", "db_name": "SQLite",
"query": "SELECT hash, message, reachable AS \"reachable: Reachable\" FROM commits JOIN commit_edges ON hash = parent WHERE child = ? ORDER BY reachable DESC, unixepoch(committer_date) ASC ", "query": "\n SELECT\n hash,\n message,\n reachable AS \"reachable: Reachable\"\n FROM commits\n JOIN queue USING (hash)\n WHERE hash = ?\n ",
"describe": { "describe": {
"columns": [ "columns": [
{ {
@ -28,5 +28,5 @@
false false
] ]
}, },
"hash": "595f95ecdafb7c94bcf4cc81222e207079e2da3779a1ce3c8b5833e335faf130" "hash": "cdc415297929fc696b8633bac5e12e6e3be1fd0dfcf188d0b778ebea92bf4a36"
} }

View file

@ -1,6 +1,6 @@
{ {
"db_name": "SQLite", "db_name": "SQLite",
"query": "SELECT hash, message, reachable AS \"reachable: Reachable\" FROM commits JOIN commit_edges ON hash = child WHERE parent = ? ORDER BY reachable DESC, unixepoch(committer_date) ASC ", "query": "\n SELECT\n hash,\n message,\n reachable AS \"reachable: Reachable\"\n FROM commits\n JOIN commit_edges ON hash = parent\n WHERE child = ?\n ORDER BY reachable DESC, unixepoch(committer_date) ASC\n ",
"describe": { "describe": {
"columns": [ "columns": [
{ {
@ -28,5 +28,5 @@
false false
] ]
}, },
"hash": "3edd8ce2a6fbb36433684d259d073cca1df369461ae8e0c357ebaba2e08186e5" "hash": "db4d8d84fe3f77b35fc9bfc6a8a154cfcd860bf6b73a534cc0c353b306d88b24"
} }

View file

@ -1,12 +0,0 @@
{
"db_name": "SQLite",
"query": "INSERT OR IGNORE INTO commits ( hash, author, author_date, committer, committer_date, message ) VALUES (?, ?, ?, ?, ?, ?) ",
"describe": {
"columns": [],
"parameters": {
"Right": 6
},
"nullable": []
},
"hash": "e2cffac014ee500f62b785172b5c115a3c504ac7d1df072dfba25ad0ac33702b"
}

View file

@ -0,0 +1,12 @@
{
"db_name": "SQLite",
"query": "\n INSERT INTO runs (\n id,\n hash,\n bench_method,\n worker_name,\n worker_info,\n start,\n end,\n exit_code\n )\n VALUES (?, ?, ?, ?, ?, ?, ?, ?)\n ",
"describe": {
"columns": [],
"parameters": {
"Right": 8
},
"nullable": []
},
"hash": "e857ba884436ab28677883a78b8244d07fefc5160182b2ba1bd53f879c596948"
}

View file

@ -1,6 +1,6 @@
{ {
"db_name": "SQLite", "db_name": "SQLite",
"query": "SELECT hash, message, reachable AS \"reachable: Reachable\" FROM commits JOIN queue USING (hash) WHERE hash = ? ", "query": "\n SELECT\n hash,\n message,\n reachable AS \"reachable: Reachable\"\n FROM commits\n JOIN commit_edges ON hash = child\n WHERE parent = ?\n ORDER BY reachable DESC, unixepoch(committer_date) ASC\n ",
"describe": { "describe": {
"columns": [ "columns": [
{ {
@ -28,5 +28,5 @@
false false
] ]
}, },
"hash": "dcd37f22be87b31a7edaba2c4225d3ddfb9802c532102036e1d2ec3cd1adc51f" "hash": "eb518fcc6d033f05fa6c679b93566b140a548b8695ea698a5cfaa9a6be6451c5"
} }

View file

@ -0,0 +1,12 @@
{
"db_name": "SQLite",
"query": "\n WITH RECURSIVE\n tracked (hash) AS (\n SELECT hash FROM refs WHERE tracked\n UNION\n SELECT parent FROM commit_edges\n JOIN tracked ON hash = child\n ),\n reachable (hash) AS (\n SELECT hash FROM refs\n UNION\n SELECT hash FROM tracked\n UNION\n SELECT parent FROM commit_edges\n JOIN reachable ON hash = child\n )\n UPDATE commits\n SET reachable = CASE\n WHEN hash IN tracked THEN ?\n WHEN hash IN reachable THEN ?\n ELSE ?\n END\n ",
"describe": {
"columns": [],
"parameters": {
"Right": 3
},
"nullable": []
},
"hash": "f5c0c5d1fc0b1eaf3fd18614c6abd5c261b130e3af0ce0a67780203ec12aefdd"
}

View file

@ -91,17 +91,8 @@ async fn insert_new_commits(
let message = commit.message_raw()?.to_string(); let message = commit.message_raw()?.to_string();
sqlx::query!( sqlx::query!(
"\ "
INSERT OR IGNORE INTO commits ( \ INSERT OR IGNORE INTO commits (
hash, \
author, \
author_date, \
committer, \
committer_date, \
message \
) \
VALUES (?, ?, ?, ?, ?, ?) \
",
hash, hash,
author, author,
author_date, author_date,
@ -109,6 +100,15 @@ async fn insert_new_commits(
committer_date, committer_date,
message message
) )
VALUES (?, ?, ?, ?, ?, ?)
",
hash,
author,
author_date,
committer,
committer_date,
message,
)
.execute(&mut *conn) .execute(&mut *conn)
.await?; .await?;
@ -182,13 +182,13 @@ async fn update_refs(conn: &mut SqliteConnection, refs: Vec<Reference>) -> someh
let hash = hash.to_string(); let hash = hash.to_string();
sqlx::query!( sqlx::query!(
"\ "
INSERT INTO refs (name, hash) VALUES (?, ?) \ INSERT INTO refs (name, hash) VALUES (?, ?)
ON CONFLICT (name) DO UPDATE \ ON CONFLICT (name) DO UPDATE
SET hash = excluded.hash \ SET hash = excluded.hash
", ",
name, name,
hash hash,
) )
.execute(&mut *conn) .execute(&mut *conn)
.await?; .await?;
@ -210,28 +210,28 @@ async fn track_main_branch(conn: &mut SqliteConnection, repo: &Repository) -> so
async fn update_commit_tracked_status(conn: &mut SqliteConnection) -> somehow::Result<()> { async fn update_commit_tracked_status(conn: &mut SqliteConnection) -> somehow::Result<()> {
sqlx::query!( sqlx::query!(
"\ "
WITH RECURSIVE \ WITH RECURSIVE
tracked (hash) AS ( \ tracked (hash) AS (
SELECT hash FROM refs WHERE tracked \ SELECT hash FROM refs WHERE tracked
UNION \ UNION
SELECT parent FROM commit_edges \ SELECT parent FROM commit_edges
JOIN tracked ON hash = child \ JOIN tracked ON hash = child
), \ ),
reachable (hash) AS ( \ reachable (hash) AS (
SELECT hash FROM refs \ SELECT hash FROM refs
UNION \ UNION
SELECT hash FROM tracked \ SELECT hash FROM tracked
UNION \ UNION
SELECT parent FROM commit_edges \ SELECT parent FROM commit_edges
JOIN reachable ON hash = child \ JOIN reachable ON hash = child
) \ )
UPDATE commits \ UPDATE commits
SET reachable = CASE \ SET reachable = CASE
WHEN hash IN tracked THEN ? \ WHEN hash IN tracked THEN ?
WHEN hash IN reachable THEN ? \ WHEN hash IN reachable THEN ?
ELSE ? \ ELSE ?
END \ END
", ",
Reachable::FromTrackedRef, Reachable::FromTrackedRef,
Reachable::FromAnyRef, Reachable::FromAnyRef,

View file

@ -36,10 +36,10 @@ pub async fn post_admin_queue_add(
) -> somehow::Result<impl IntoResponse> { ) -> somehow::Result<impl IntoResponse> {
let date = OffsetDateTime::now_utc(); let date = OffsetDateTime::now_utc();
sqlx::query!( sqlx::query!(
"\ "
INSERT INTO queue (hash, date, priority) VALUES (?, ?, ?) \ INSERT INTO queue (hash, date, priority) VALUES (?, ?, ?)
ON CONFLICT (hash) DO UPDATE \ ON CONFLICT (hash) DO UPDATE
SET priority = excluded.priority WHERE priority < excluded.priority \ SET priority = excluded.priority WHERE priority < excluded.priority
", ",
form.hash, form.hash,
date, date,
@ -71,14 +71,14 @@ pub async fn post_admin_queue_add_batch(
) -> somehow::Result<impl IntoResponse> { ) -> somehow::Result<impl IntoResponse> {
let date = OffsetDateTime::now_utc(); let date = OffsetDateTime::now_utc();
let added = sqlx::query!( let added = sqlx::query!(
"\ "
INSERT OR IGNORE INTO queue (hash, date, priority) \ INSERT OR IGNORE INTO queue (hash, date, priority)
SELECT hash, ?, ? \ SELECT hash, ?, ?
FROM commits \ FROM commits
LEFT JOIN runs USING (hash) \ LEFT JOIN runs USING (hash)
WHERE reachable = ? AND id IS NULL \ WHERE reachable = ? AND id IS NULL
ORDER BY unixepoch(committer_date) DESC \ ORDER BY unixepoch(committer_date) DESC
LIMIT ? \ LIMIT ?
", ",
date, date,
form.priority, form.priority,
@ -132,7 +132,7 @@ pub async fn post_admin_queue_increase(
) -> somehow::Result<impl IntoResponse> { ) -> somehow::Result<impl IntoResponse> {
sqlx::query!( sqlx::query!(
"UPDATE queue SET priority = priority + 1 WHERE hash = ?", "UPDATE queue SET priority = priority + 1 WHERE hash = ?",
form.hash form.hash,
) )
.execute(&db) .execute(&db)
.await?; .await?;
@ -155,7 +155,7 @@ pub async fn post_admin_queue_decrease(
) -> somehow::Result<impl IntoResponse> { ) -> somehow::Result<impl IntoResponse> {
sqlx::query!( sqlx::query!(
"UPDATE queue SET priority = priority - 1 WHERE hash = ?", "UPDATE queue SET priority = priority - 1 WHERE hash = ?",
form.hash form.hash,
) )
.execute(&db) .execute(&db)
.await?; .await?;

View file

@ -45,18 +45,18 @@ async fn save_work(
let end = run.end.map(|t| t.0).unwrap_or_else(OffsetDateTime::now_utc); let end = run.end.map(|t| t.0).unwrap_or_else(OffsetDateTime::now_utc);
sqlx::query!( sqlx::query!(
"\ "
INSERT INTO runs ( \ INSERT INTO runs (
id, \ id,
hash, \ hash,
bench_method, \ bench_method,
worker_name, \ worker_name,
worker_info, \ worker_info,
start, \ start,
end, \ end,
exit_code \ exit_code
) \ )
VALUES (?, ?, ?, ?, ?, ?, ?, ?) \ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
", ",
run.id, run.id,
run.hash, run.hash,
@ -78,14 +78,14 @@ async fn save_work(
for (metric, measurement) in run.measurements { for (metric, measurement) in run.measurements {
sqlx::query!( sqlx::query!(
"\ "
INSERT INTO run_measurements ( \ INSERT INTO run_measurements (
id, \ id,
metric, \ metric,
value, \ value,
unit \ unit
) \ )
VALUES (?, ?, ?, ?) \ VALUES (?, ?, ?, ?)
", ",
run.id, run.id,
metric, metric,
@ -100,14 +100,14 @@ async fn save_work(
// Hopefully we won't need more than 4294967296 lines per run :P // Hopefully we won't need more than 4294967296 lines per run :P
let line = line as u32; let line = line as u32;
sqlx::query!( sqlx::query!(
"\ "
INSERT INTO run_output ( \ INSERT INTO run_output (
id, \ id,
line, \ line,
source, \ source,
text \ text
) \ )
VALUES (?, ?, ?, ?) \ VALUES (?, ?, ?, ?)
", ",
run.id, run.id,
line, line,

View file

@ -28,18 +28,18 @@ pub async fn get_commit_by_hash(
State(db): State<SqlitePool>, State(db): State<SqlitePool>,
) -> somehow::Result<Response> { ) -> somehow::Result<Response> {
let Some(commit) = sqlx::query!( let Some(commit) = sqlx::query!(
"\ r#"
SELECT \ SELECT
hash, \ hash,
author, \ author,
author_date AS \"author_date: time::OffsetDateTime\", \ author_date AS "author_date: time::OffsetDateTime",
committer, \ committer,
committer_date AS \"committer_date: time::OffsetDateTime\", \ committer_date AS "committer_date: time::OffsetDateTime",
message, \ message,
reachable AS \"reachable: Reachable\" \ reachable AS "reachable: Reachable"
FROM commits \ FROM commits
WHERE hash = ? \ WHERE hash = ?
", "#,
path.hash, path.hash,
) )
.fetch_optional(&db) .fetch_optional(&db)
@ -49,16 +49,16 @@ pub async fn get_commit_by_hash(
}; };
let parents = sqlx::query!( let parents = sqlx::query!(
"\ r#"
SELECT \ SELECT
hash, \ hash,
message, \ message,
reachable AS \"reachable: Reachable\" \ reachable AS "reachable: Reachable"
FROM commits \ FROM commits
JOIN commit_edges ON hash = parent \ JOIN commit_edges ON hash = parent
WHERE child = ? \ WHERE child = ?
ORDER BY reachable DESC, unixepoch(committer_date) ASC \ ORDER BY reachable DESC, unixepoch(committer_date) ASC
", "#,
path.hash, path.hash,
) )
.fetch(&db) .fetch(&db)
@ -67,16 +67,16 @@ pub async fn get_commit_by_hash(
.await?; .await?;
let children = sqlx::query!( let children = sqlx::query!(
"\ r#"
SELECT \ SELECT
hash, \ hash,
message, \ message,
reachable AS \"reachable: Reachable\" \ reachable AS "reachable: Reachable"
FROM commits \ FROM commits
JOIN commit_edges ON hash = child \ JOIN commit_edges ON hash = child
WHERE parent = ? \ WHERE parent = ?
ORDER BY reachable DESC, unixepoch(committer_date) ASC \ ORDER BY reachable DESC, unixepoch(committer_date) ASC
", "#,
path.hash, path.hash,
) )
.fetch(&db) .fetch(&db)
@ -85,13 +85,13 @@ pub async fn get_commit_by_hash(
.await?; .await?;
let runs = sqlx::query!( let runs = sqlx::query!(
"\ r#"
SELECT \ SELECT
id, \ id,
start AS \"start: time::OffsetDateTime\" \ start AS "start: time::OffsetDateTime"
FROM runs WHERE hash = ? \ FROM runs WHERE hash = ?
", "#,
path.hash path.hash,
) )
.fetch(&db) .fetch(&db)
.map_ok(|r| components::link_run_date(config, r.id, r.start)) .map_ok(|r| components::link_run_date(config, r.id, r.start))

View file

@ -93,16 +93,16 @@ pub async fn get_graph_commits(
// Fetch main commit info // Fetch main commit info
let mut rows = sqlx::query!( let mut rows = sqlx::query!(
"\ r#"
SELECT \ SELECT
hash, \ hash,
author, \ author,
message, \ message,
committer_date AS \"committer_date: OffsetDateTime\" \ committer_date AS "committer_date: OffsetDateTime"
FROM commits \ FROM commits
WHERE reachable = ? \ WHERE reachable = ?
ORDER BY hash ASC \ ORDER BY hash ASC
", "#,
Reachable::FromTrackedRef, Reachable::FromTrackedRef,
) )
.fetch(&mut *conn); .fetch(&mut *conn);
@ -124,12 +124,12 @@ pub async fn get_graph_commits(
// Fetch parent info // Fetch parent info
let mut rows = sqlx::query!( let mut rows = sqlx::query!(
"\ "
SELECT child, parent \ SELECT child, parent
FROM commit_edges \ FROM commit_edges
JOIN commits ON hash = child \ JOIN commits ON hash = child
WHERE reachable = ? \ WHERE reachable = ?
ORDER BY hash ASC \ ORDER BY hash ASC
", ",
Reachable::FromTrackedRef, Reachable::FromTrackedRef,
) )

View file

@ -27,17 +27,17 @@ pub async fn get_index(
State(db): State<SqlitePool>, State(db): State<SqlitePool>,
) -> somehow::Result<impl IntoResponse> { ) -> somehow::Result<impl IntoResponse> {
let refs = sqlx::query!( let refs = sqlx::query!(
"\ r#"
SELECT \ SELECT
name, \ name,
hash, \ hash,
message, \ message,
reachable AS \"reachable: Reachable\", \ reachable AS "reachable: Reachable",
tracked \ tracked
FROM refs \ FROM refs
JOIN commits USING (hash) \ JOIN commits USING (hash)
ORDER BY name ASC \ ORDER BY name ASC
" "#
) )
.fetch(&db) .fetch(&db)
.map_ok(|r| Ref { .map_ok(|r| Ref {

View file

@ -117,17 +117,17 @@ async fn get_queue_data(
} }
let mut tasks = sqlx::query!( let mut tasks = sqlx::query!(
"\ r#"
SELECT \ SELECT
hash, \ hash,
message, \ message,
reachable AS \"reachable: Reachable\", \ reachable AS "reachable: Reachable",
date AS \"date: time::OffsetDateTime\", \ date AS "date: time::OffsetDateTime",
priority \ priority
FROM queue \ FROM queue
JOIN commits USING (hash) \ JOIN commits USING (hash)
ORDER BY priority DESC, unixepoch(date) DESC, hash ASC \ ORDER BY priority DESC, unixepoch(date) DESC, hash ASC
" "#
) )
.fetch(db) .fetch(db)
.map_ok(|r| Task { .map_ok(|r| Task {
@ -276,15 +276,15 @@ pub async fn get_queue_delete(
State(db): State<SqlitePool>, State(db): State<SqlitePool>,
) -> somehow::Result<Response> { ) -> somehow::Result<Response> {
let Some(r) = sqlx::query!( let Some(r) = sqlx::query!(
"\ r#"
SELECT \ SELECT
hash, \ hash,
message, \ message,
reachable AS \"reachable: Reachable\" \ reachable AS "reachable: Reachable"
FROM commits \ FROM commits
JOIN queue USING (hash) \ JOIN queue USING (hash)
WHERE hash = ? \ WHERE hash = ?
", "#,
path.hash, path.hash,
) )
.fetch_optional(&db) .fetch_optional(&db)

View file

@ -34,20 +34,20 @@ async fn from_finished_run(
db: &SqlitePool, db: &SqlitePool,
) -> somehow::Result<Option<Markup>> { ) -> somehow::Result<Option<Markup>> {
let Some(run) = sqlx::query!( let Some(run) = sqlx::query!(
"\ r#"
SELECT \ SELECT
id, \ id,
hash, \ hash,
bench_method, \ bench_method,
start AS \"start: time::OffsetDateTime\", \ start AS "start: time::OffsetDateTime",
end AS \"end: time::OffsetDateTime\", \ end AS "end: time::OffsetDateTime",
exit_code, \ exit_code,
message, \ message,
reachable AS \"reachable: Reachable\" \ reachable AS "reachable: Reachable"
FROM runs \ FROM runs
JOIN commits USING (hash) \ JOIN commits USING (hash)
WHERE id = ? \ WHERE id = ?
", "#,
id, id,
) )
.fetch_optional(db) .fetch_optional(db)
@ -57,14 +57,14 @@ async fn from_finished_run(
}; };
let measurements = sqlx::query!( let measurements = sqlx::query!(
"\ "
SELECT \ SELECT
metric, \ metric,
value, \ value,
unit \ unit
FROM run_measurements \ FROM run_measurements
WHERE id = ? \ WHERE id = ?
ORDER BY metric ASC \ ORDER BY metric ASC
", ",
id, id,
) )
@ -78,10 +78,10 @@ async fn from_finished_run(
.await?; .await?;
let output = sqlx::query!( let output = sqlx::query!(
"\ "
SELECT source, text FROM run_output \ SELECT source, text FROM run_output
WHERE id = ? \ WHERE id = ?
ORDER BY line ASC \ ORDER BY line ASC
", ",
id, id,
) )