Create and use Reachable primitive
This commit is contained in:
parent
5a4784be56
commit
7d80ba4a6b
24 changed files with 136 additions and 87 deletions
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "INSERT OR IGNORE INTO queue (hash, date, priority) SELECT hash, ?, ? FROM commits LEFT JOIN runs USING (hash) WHERE reachable = 2 AND id IS NULL ORDER BY unixepoch(committer_date) DESC LIMIT ? ",
|
||||
"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": 3
|
||||
"Right": 4
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "ee811ca799590d80f1c76a8625ab22c584e528b4dac6ee1103c071eb29282f17"
|
||||
"hash": "1b572ecd6904a13d78070bc6aeef3a4f349baa5b880aaa1d141b516a34517b4b"
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "SELECT name, hash, message, reachable, tracked FROM refs JOIN commits USING (hash) ORDER BY name ASC ",
|
||||
"query": "SELECT name, hash, message, reachable AS \"reachable: Reachable\", tracked FROM refs JOIN commits USING (hash) ORDER BY name ASC ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"name": "reachable",
|
||||
"name": "reachable: Reachable",
|
||||
"ordinal": 3,
|
||||
"type_info": "Int64"
|
||||
},
|
||||
|
|
@ -40,5 +40,5 @@
|
|||
false
|
||||
]
|
||||
},
|
||||
"hash": "c7a4115d81a3371d77afadfdad7dbe47c4d1d23211a35c0c68174f9ce82893c2"
|
||||
"hash": "1df8ec0b41dbafe191f6990d6be6f6f3c9d86ea9ca8112f16b5735b1193ea243"
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "SELECT hash, author, message, committer_date AS \"committer_date: OffsetDateTime\" FROM commits WHERE reachable = 2 ORDER BY hash ASC ",
|
||||
"query": "SELECT hash, author, message, committer_date AS \"committer_date: OffsetDateTime\" FROM commits WHERE reachable = ? ORDER BY hash ASC ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 0
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
|
|
@ -34,5 +34,5 @@
|
|||
false
|
||||
]
|
||||
},
|
||||
"hash": "6c766f5d504a19061a551b0b11b1558d08702ff3656331cb2595c9dc311cd870"
|
||||
"hash": "2d4ddb045e286955334793d7610f1f1ee1d7d825031b003db6117231a16d2f50"
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "UPDATE commits SET new = false WHERE reachable = 2",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 0
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "3d48dcc84c3d624f7a9f9ebd0399aa9786cb94e2ddda6016fc0e8e0fee46fc98"
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "SELECT hash, message, reachable FROM commits JOIN commit_edges ON hash = parent WHERE child = ? ORDER BY reachable DESC, unixepoch(committer_date) ASC ",
|
||||
"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 ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"name": "reachable",
|
||||
"name": "reachable: Reachable",
|
||||
"ordinal": 2,
|
||||
"type_info": "Int64"
|
||||
}
|
||||
|
|
@ -28,5 +28,5 @@
|
|||
false
|
||||
]
|
||||
},
|
||||
"hash": "3514cb91d76683ccdf40ef732ae6062327d6b4aa1acd96632cb934b2d8495b9d"
|
||||
"hash": "3edd8ce2a6fbb36433684d259d073cca1df369461ae8e0c357ebaba2e08186e5"
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "SELECT hash FROM commits WHERE new AND reachable = 2",
|
||||
"query": "SELECT hash FROM commits WHERE new AND reachable = ?",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
|
|
@ -10,11 +10,11 @@
|
|||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 0
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "726102c4f61f95047a64cdc21834d0a5544950ecfe9b1d6716521dcf1d0b8fb2"
|
||||
"hash": "4adebcd260affd90435d3b3b3cf1bbee3bec22d5745b45184c3f555b9c5e9e31"
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "SELECT hash, message, reachable FROM commits JOIN commit_edges ON hash = child WHERE parent = ? ORDER BY reachable DESC, unixepoch(committer_date) ASC ",
|
||||
"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 ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"name": "reachable",
|
||||
"name": "reachable: Reachable",
|
||||
"ordinal": 2,
|
||||
"type_info": "Int64"
|
||||
}
|
||||
|
|
@ -28,5 +28,5 @@
|
|||
false
|
||||
]
|
||||
},
|
||||
"hash": "a6d9bfe6d0cd4677074341cebe6a3cc9c1ed2273ab238bd18a435abff4564c67"
|
||||
"hash": "595f95ecdafb7c94bcf4cc81222e207079e2da3779a1ce3c8b5833e335faf130"
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "SELECT hash, message, reachable, date AS \"date: time::OffsetDateTime\", priority FROM queue JOIN commits USING (hash) ORDER BY priority DESC, unixepoch(date) DESC, hash ASC ",
|
||||
"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 ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"name": "reachable",
|
||||
"name": "reachable: Reachable",
|
||||
"ordinal": 2,
|
||||
"type_info": "Int64"
|
||||
},
|
||||
|
|
@ -40,5 +40,5 @@
|
|||
false
|
||||
]
|
||||
},
|
||||
"hash": "6c9e27efd2c88772bbf1f89bf53d0abb49cd82788b1e88e4e2ef153b0f35a8fb"
|
||||
"hash": "5da81c9c9875bf4fd4e894ca54be65aee3d76a26c12feb1e4f25e9f482cd153e"
|
||||
}
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"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 2 WHEN hash IN reachable THEN 1 ELSE 0 END ",
|
||||
"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": 0
|
||||
"Right": 3
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "32f0ac59687e5455bb38060dc1d6cd181a86cd6ca7ac2f583a33212c8b7bef1a"
|
||||
"hash": "7808509e5f7d1c7e8138ff9e124ab3b1784a05ac771778ff8e503ae20d319c08"
|
||||
}
|
||||
12
.sqlx/query-b59a8a7243290e78dbfedc6b2577097bc0220317ad69eb22173ae8cf8c85a0d3.json
generated
Normal file
12
.sqlx/query-b59a8a7243290e78dbfedc6b2577097bc0220317ad69eb22173ae8cf8c85a0d3.json
generated
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "UPDATE commits SET new = false WHERE reachable = ?",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "b59a8a7243290e78dbfedc6b2577097bc0220317ad69eb22173ae8cf8c85a0d3"
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "SELECT child, parent FROM commit_edges JOIN commits ON hash = child WHERE reachable = 2 ORDER BY hash ASC ",
|
||||
"query": "SELECT child, parent FROM commit_edges JOIN commits ON hash = child WHERE reachable = ? ORDER BY hash ASC ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
|
|
@ -15,12 +15,12 @@
|
|||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 0
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "5092d460f9bd489e2a5905c1ae3e3d3b3c946c427e1dd7d2d723f6aab5acd636"
|
||||
"hash": "ba09c191e2a83d4398b26888f041c93095ba82693b0b9c2c2eebd65078f7d168"
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "SELECT hash, author, author_date AS \"author_date: time::OffsetDateTime\", committer, committer_date AS \"committer_date: time::OffsetDateTime\", message, reachable FROM commits WHERE hash = ? ",
|
||||
"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 = ? ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"name": "reachable",
|
||||
"name": "reachable: Reachable",
|
||||
"ordinal": 6,
|
||||
"type_info": "Int64"
|
||||
}
|
||||
|
|
@ -52,5 +52,5 @@
|
|||
false
|
||||
]
|
||||
},
|
||||
"hash": "a42862017ade20eb742a9761c1b581d4c902dfe12e36a504cc111a9d38407196"
|
||||
"hash": "c75001269238285e4de8d609a404b7249df61711324b3cae4c21b74b0875100d"
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "SELECT id, hash, bench_method, start AS \"start: time::OffsetDateTime\", end AS \"end: time::OffsetDateTime\", exit_code, message, reachable FROM runs JOIN commits USING (hash) WHERE id = ? ",
|
||||
"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 = ? ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"name": "reachable",
|
||||
"name": "reachable: Reachable",
|
||||
"ordinal": 7,
|
||||
"type_info": "Int64"
|
||||
}
|
||||
|
|
@ -58,5 +58,5 @@
|
|||
false
|
||||
]
|
||||
},
|
||||
"hash": "26bf8f43e0fa607ddfabb0611ee95c8ed1fef2d1aa76749b660228cd38a84283"
|
||||
"hash": "daae5a05af0e8a511f5099820da2ccbeebb577935786fdb1a235d0315bc5a433"
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "SELECT hash, message, reachable FROM commits JOIN queue USING (hash) WHERE hash = ? ",
|
||||
"query": "SELECT hash, message, reachable AS \"reachable: Reachable\" FROM commits JOIN queue USING (hash) WHERE hash = ? ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"name": "reachable",
|
||||
"name": "reachable: Reachable",
|
||||
"ordinal": 2,
|
||||
"type_info": "Int64"
|
||||
}
|
||||
|
|
@ -28,5 +28,5 @@
|
|||
false
|
||||
]
|
||||
},
|
||||
"hash": "c1e772c34a0324159ca1ee204806c3774762a3df4c6d06a4ea4df67b105bac00"
|
||||
"hash": "dcd37f22be87b31a7edaba2c4225d3ddfb9802c532102036e1d2ec3cd1adc51f"
|
||||
}
|
||||
|
|
@ -22,6 +22,15 @@ pub enum Direction {
|
|||
MoreIsBetter = 1,
|
||||
}
|
||||
|
||||
/// How a commit can be reached from refs.
|
||||
#[derive(Debug, Clone, Serialize_repr, Deserialize_repr, sqlx::Type)]
|
||||
#[repr(u8)]
|
||||
pub enum Reachable {
|
||||
Unreachable = 0,
|
||||
FromAnyRef = 1,
|
||||
FromTrackedRef = 2,
|
||||
}
|
||||
|
||||
/// A time stamp, usually formatted using RFC3339.
|
||||
#[derive(Clone, Copy, sqlx::Type)]
|
||||
#[sqlx(transparent)]
|
||||
|
|
|
|||
|
|
@ -2,14 +2,17 @@ use log::{debug, info, warn};
|
|||
use sqlx::{Acquire, SqlitePool};
|
||||
use time::OffsetDateTime;
|
||||
|
||||
use crate::somehow;
|
||||
use crate::{primitive::Reachable, somehow};
|
||||
|
||||
async fn inner(db: &SqlitePool) -> somehow::Result<()> {
|
||||
let mut tx = db.begin().await?;
|
||||
let conn = tx.acquire().await?;
|
||||
|
||||
// Get all newly added tracked commits
|
||||
let new = sqlx::query!("SELECT hash FROM commits WHERE new AND reachable = 2")
|
||||
let new = sqlx::query!(
|
||||
"SELECT hash FROM commits WHERE new AND reachable = ?",
|
||||
Reachable::FromTrackedRef,
|
||||
)
|
||||
.fetch_all(&mut *conn)
|
||||
.await?;
|
||||
debug!("Found {} new commits", new.len());
|
||||
|
|
@ -38,10 +41,14 @@ async fn inner(db: &SqlitePool) -> somehow::Result<()> {
|
|||
//
|
||||
// When tracked refs are updated, all new commits are automatically added to
|
||||
// the queue, since they were still new and have now transitioned to
|
||||
// reachable = 2. This should hopefully not be too big of a problem since
|
||||
// usually the main branch is also tracked. I think I'd rather implement
|
||||
// better queue management tools and graph UI than change this behaviour.
|
||||
let amount = sqlx::query!("UPDATE commits SET new = false WHERE reachable = 2")
|
||||
// Reachable::FromTrackedRef. This should hopefully not be too big of a
|
||||
// problem since usually the main branch is also tracked. I think I'd rather
|
||||
// implement better queue management tools and graph UI than change this
|
||||
// behaviour.
|
||||
let amount = sqlx::query!(
|
||||
"UPDATE commits SET new = false WHERE reachable = ?",
|
||||
Reachable::FromTrackedRef,
|
||||
)
|
||||
.execute(&mut *conn)
|
||||
.await?
|
||||
.rows_affected();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use sqlx::{Acquire, SqliteConnection, SqlitePool};
|
|||
use time::{OffsetDateTime, UtcOffset};
|
||||
|
||||
use crate::{
|
||||
primitive::Reachable,
|
||||
server::{format, Repo},
|
||||
somehow,
|
||||
};
|
||||
|
|
@ -227,11 +228,14 @@ async fn update_commit_tracked_status(conn: &mut SqliteConnection) -> somehow::R
|
|||
) \
|
||||
UPDATE commits \
|
||||
SET reachable = CASE \
|
||||
WHEN hash IN tracked THEN 2 \
|
||||
WHEN hash IN reachable THEN 1 \
|
||||
ELSE 0 \
|
||||
WHEN hash IN tracked THEN ? \
|
||||
WHEN hash IN reachable THEN ? \
|
||||
ELSE ? \
|
||||
END \
|
||||
"
|
||||
",
|
||||
Reachable::FromTrackedRef,
|
||||
Reachable::FromAnyRef,
|
||||
Reachable::Unreachable,
|
||||
)
|
||||
.execute(conn)
|
||||
.await?;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use time::OffsetDateTime;
|
|||
|
||||
use crate::{
|
||||
config::ServerConfig,
|
||||
primitive::Reachable,
|
||||
server::web::{
|
||||
paths::{
|
||||
PathAdminQueueAdd, PathAdminQueueAddBatch, PathAdminQueueDecrease,
|
||||
|
|
@ -75,12 +76,13 @@ pub async fn post_admin_queue_add_batch(
|
|||
SELECT hash, ?, ? \
|
||||
FROM commits \
|
||||
LEFT JOIN runs USING (hash) \
|
||||
WHERE reachable = 2 AND id IS NULL \
|
||||
WHERE reachable = ? AND id IS NULL \
|
||||
ORDER BY unixepoch(committer_date) DESC \
|
||||
LIMIT ? \
|
||||
",
|
||||
date,
|
||||
form.priority,
|
||||
Reachable::FromTrackedRef,
|
||||
form.amount,
|
||||
)
|
||||
.execute(&db)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use maud::{html, Markup};
|
||||
use time::OffsetDateTime;
|
||||
|
||||
use crate::{config::ServerConfig, server::format};
|
||||
use crate::{config::ServerConfig, primitive::Reachable, server::format};
|
||||
|
||||
use super::{
|
||||
paths::{PathCommitByHash, PathRunById, PathWorkerByName},
|
||||
|
|
@ -17,26 +17,29 @@ pub fn join(sections: &[Markup], with: Markup) -> Markup {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn commit_class_and_title(reachable: i64) -> (&'static str, &'static str) {
|
||||
if reachable == 0 {
|
||||
(
|
||||
pub fn commit_class_and_title(reachable: Reachable) -> (&'static str, &'static str) {
|
||||
match reachable {
|
||||
Reachable::Unreachable => (
|
||||
"commit-orphaned",
|
||||
"This commit is orphaned. It can't be reached from any ref.",
|
||||
)
|
||||
} else if reachable == -1 {
|
||||
(
|
||||
),
|
||||
Reachable::FromAnyRef => (
|
||||
"commit-reachable",
|
||||
"This commit can only be reached from untracked refs.",
|
||||
)
|
||||
} else {
|
||||
(
|
||||
),
|
||||
Reachable::FromTrackedRef => (
|
||||
"commit-tracked",
|
||||
"This commit can be reached from a tracked ref.",
|
||||
)
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn link_commit(config: &ServerConfig, hash: String, message: &str, reachable: i64) -> Markup {
|
||||
pub fn link_commit(
|
||||
config: &ServerConfig,
|
||||
hash: String,
|
||||
message: &str,
|
||||
reachable: Reachable,
|
||||
) -> Markup {
|
||||
let short = format::truncate(&format::commit_short(&hash, message), 80);
|
||||
let path = config.path(PathCommitByHash { hash });
|
||||
let (class, title) = commit_class_and_title(reachable);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use sqlx::SqlitePool;
|
|||
|
||||
use crate::{
|
||||
config::ServerConfig,
|
||||
primitive::Reachable,
|
||||
server::{
|
||||
format,
|
||||
web::{
|
||||
|
|
@ -35,7 +36,7 @@ pub async fn get_commit_by_hash(
|
|||
committer, \
|
||||
committer_date AS \"committer_date: time::OffsetDateTime\", \
|
||||
message, \
|
||||
reachable \
|
||||
reachable AS \"reachable: Reachable\" \
|
||||
FROM commits \
|
||||
WHERE hash = ? \
|
||||
",
|
||||
|
|
@ -49,7 +50,11 @@ pub async fn get_commit_by_hash(
|
|||
|
||||
let parents = sqlx::query!(
|
||||
"\
|
||||
SELECT hash, message, reachable FROM commits \
|
||||
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 \
|
||||
|
|
@ -63,7 +68,11 @@ pub async fn get_commit_by_hash(
|
|||
|
||||
let children = sqlx::query!(
|
||||
"\
|
||||
SELECT hash, message, reachable FROM commits \
|
||||
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 \
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use time::OffsetDateTime;
|
|||
|
||||
use crate::{
|
||||
config::ServerConfig,
|
||||
primitive::Reachable,
|
||||
server::{
|
||||
format,
|
||||
web::{
|
||||
|
|
@ -99,9 +100,10 @@ pub async fn get_graph_commits(
|
|||
message, \
|
||||
committer_date AS \"committer_date: OffsetDateTime\" \
|
||||
FROM commits \
|
||||
WHERE reachable = 2 \
|
||||
WHERE reachable = ? \
|
||||
ORDER BY hash ASC \
|
||||
"
|
||||
",
|
||||
Reachable::FromTrackedRef,
|
||||
)
|
||||
.fetch(&mut *conn);
|
||||
while let Some(row) = rows.try_next().await? {
|
||||
|
|
@ -126,9 +128,10 @@ pub async fn get_graph_commits(
|
|||
SELECT child, parent \
|
||||
FROM commit_edges \
|
||||
JOIN commits ON hash = child \
|
||||
WHERE reachable = 2 \
|
||||
WHERE reachable = ? \
|
||||
ORDER BY hash ASC \
|
||||
"
|
||||
",
|
||||
Reachable::FromTrackedRef,
|
||||
)
|
||||
.fetch(&mut *conn);
|
||||
while let Some(row) = rows.try_next().await? {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ use sqlx::SqlitePool;
|
|||
|
||||
use crate::{
|
||||
config::ServerConfig,
|
||||
primitive::Reachable,
|
||||
server::web::{
|
||||
components,
|
||||
page::{Page, Tab},
|
||||
|
|
@ -27,7 +28,12 @@ pub async fn get_index(
|
|||
) -> somehow::Result<impl IntoResponse> {
|
||||
let refs = sqlx::query!(
|
||||
"\
|
||||
SELECT name, hash, message, reachable, tracked \
|
||||
SELECT \
|
||||
name, \
|
||||
hash, \
|
||||
message, \
|
||||
reachable AS \"reachable: Reachable\", \
|
||||
tracked \
|
||||
FROM refs \
|
||||
JOIN commits USING (hash) \
|
||||
ORDER BY name ASC \
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use sqlx::SqlitePool;
|
|||
|
||||
use crate::{
|
||||
config::ServerConfig,
|
||||
primitive::Reachable,
|
||||
server::{
|
||||
format,
|
||||
web::{
|
||||
|
|
@ -120,7 +121,7 @@ async fn get_queue_data(
|
|||
SELECT \
|
||||
hash, \
|
||||
message, \
|
||||
reachable, \
|
||||
reachable AS \"reachable: Reachable\", \
|
||||
date AS \"date: time::OffsetDateTime\", \
|
||||
priority \
|
||||
FROM queue \
|
||||
|
|
@ -276,7 +277,11 @@ pub async fn get_queue_delete(
|
|||
) -> somehow::Result<Response> {
|
||||
let Some(r) = sqlx::query!(
|
||||
"\
|
||||
SELECT hash, message, reachable FROM commits \
|
||||
SELECT \
|
||||
hash, \
|
||||
message, \
|
||||
reachable AS \"reachable: Reachable\" \
|
||||
FROM commits \
|
||||
JOIN queue USING (hash) \
|
||||
WHERE hash = ? \
|
||||
",
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use sqlx::SqlitePool;
|
|||
|
||||
use crate::{
|
||||
config::ServerConfig,
|
||||
primitive::Reachable,
|
||||
server::{
|
||||
format,
|
||||
web::{components, page::Page, paths::PathRunById},
|
||||
|
|
@ -42,7 +43,7 @@ async fn from_finished_run(
|
|||
end AS \"end: time::OffsetDateTime\", \
|
||||
exit_code, \
|
||||
message, \
|
||||
reachable \
|
||||
reachable AS \"reachable: Reachable\" \
|
||||
FROM runs \
|
||||
JOIN commits USING (hash) \
|
||||
WHERE id = ? \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue