Compare commits

..

4 commits

Author SHA1 Message Date
Simon Bruder 1d831585bd
flake: Update pre-commit-hooks.nix to new name
All checks were successful
/ build (push) Successful in 26s
This also removes all input overrides.
2024-07-24 00:14:02 +02:00
Simon Bruder a72d5b40e2
CI: Only gate OCI image push on branch
All checks were successful
/ build (push) Successful in 3m31s
2024-07-24 00:07:56 +02:00
Simon Bruder 1f6298af4a
Remove home link from navbar
There is nothing there and it can also be reached by clicking on the
branding.
2024-07-21 23:46:15 +02:00
Simon Bruder 5b3dd34312
Move away from models and manage subpackage
This architecture was started when the project still used Diesel.
Now that it uses SQLx, less things are done in Rust and more are done in
SQL. This commit now moves more of the query logic into SQL, which
should lead to more efficient queries and less moving data around.
2024-07-21 23:43:53 +02:00
2 changed files with 8 additions and 10 deletions

View file

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "\n WITH RECURSIVE cte AS (\n SELECT\n id,\n ARRAY[]::UUID[] AS parents,\n ARRAY[]::VARCHAR[] AS parent_names,\n ARRAY[]::VARCHAR[] AS parent_class_names\n FROM items\n WHERE parent IS NULL\n\n UNION\n\n SELECT\n items.id,\n cte.parents || items.parent,\n cte.parent_names || parent.name,\n cte.parent_class_names || parent_class.name\n FROM cte\n JOIN items\n ON items.parent = cte.id\n JOIN items AS \"parent\"\n ON parent.id = cte.id\n JOIN item_classes AS \"parent_class\"\n ON parent.class = parent_class.id\n )\n SELECT\n cte.id AS \"id!\",\n items.name,\n items.class,\n item_classes.name AS \"class_name\",\n cte.parents AS \"parents!\",\n cte.parent_names AS \"parent_names!: Vec<Option<String>>\",\n cte.parent_class_names AS \"parent_class_names!\"\n FROM cte\n JOIN items\n ON cte.id = items.id\n JOIN item_classes\n ON items.class = item_classes.id\n ORDER BY items.created_at\n ",
"query": "\n WITH RECURSIVE cte AS (\n SELECT\n id,\n ARRAY[]::UUID[] AS parents,\n ARRAY[]::VARCHAR[] AS parent_names,\n ARRAY[]::VARCHAR[] AS parent_class_names\n FROM items\n WHERE parent IS NULL\n\n UNION\n\n SELECT\n items.id,\n cte.parents || items.parent,\n cte.parent_names || items.name,\n cte.parent_class_names || item_classes.name\n FROM items\n JOIN cte\n ON items.parent = cte.id\n JOIN item_classes\n ON items.class = item_classes.id\n )\n SELECT\n cte.id AS \"id!\",\n items.name,\n items.class,\n item_classes.name AS \"class_name\",\n cte.parents AS \"parents!\",\n cte.parent_names AS \"parent_names!: Vec<Option<String>>\",\n cte.parent_class_names AS \"parent_class_names!\"\n FROM cte\n JOIN items\n ON cte.id = items.id\n JOIN item_classes\n ON items.class = item_classes.id\n ORDER BY items.created_at\n ",
"describe": {
"columns": [
{
@ -52,5 +52,5 @@
null
]
},
"hash": "3dedb7b184103c1d418f7b94e26c75aea0c7d22e009299d1b87443e350578171"
"hash": "5dac9aa215abdc07cda1f4d46db4bcafec45b6264efcb8a175580a71e48c7421"
}

View file

@ -44,15 +44,13 @@ async fn get(pool: web::Data<PgPool>, user: Identity) -> actix_web::Result<impl
SELECT
items.id,
cte.parents || items.parent,
cte.parent_names || parent.name,
cte.parent_class_names || parent_class.name
FROM cte
JOIN items
cte.parent_names || items.name,
cte.parent_class_names || item_classes.name
FROM items
JOIN cte
ON items.parent = cte.id
JOIN items AS "parent"
ON parent.id = cte.id
JOIN item_classes AS "parent_class"
ON parent.class = parent_class.id
JOIN item_classes
ON items.class = item_classes.id
)
SELECT
cte.id AS "id!",