From 020c68992e0bc4a9389fb855204f44bef4333585 Mon Sep 17 00:00:00 2001 From: Script Raccoon Date: Sun, 17 May 2026 20:58:48 +0200 Subject: [PATCH 1/3] show which categories use a given implication --- src/routes/app.css | 4 ++ .../category-implication/[id]/+page.server.ts | 46 ++++++++++++------- .../category-implication/[id]/+page.svelte | 14 ++++++ 3 files changed, 47 insertions(+), 17 deletions(-) diff --git a/src/routes/app.css b/src/routes/app.css index 78ad04589..a91a6a64d 100644 --- a/src/routes/app.css +++ b/src/routes/app.css @@ -111,6 +111,10 @@ p { margin-block: 1rem; } +details { + margin-block: 1rem; +} + a { color: inherit; text-underline-offset: 2px; diff --git a/src/routes/category-implication/[id]/+page.server.ts b/src/routes/category-implication/[id]/+page.server.ts index 8d72521ae..de3769bed 100644 --- a/src/routes/category-implication/[id]/+page.server.ts +++ b/src/routes/category-implication/[id]/+page.server.ts @@ -1,5 +1,5 @@ -import type { ImplicationDB, ImplicationDisplay } from '$lib/commons/types' -import { query } from '$lib/server/db.catdat' +import type { CategoryShort, ImplicationDB, ImplicationDisplay } from '$lib/commons/types' +import { batch } from '$lib/server/db.catdat' import { render_nested_formulas } from '$lib/server/formulas' import { display_implication } from '$lib/server/utils' import { error } from '@sveltejs/kit' @@ -8,24 +8,36 @@ import sql from 'sql-template-tag' export const load = async (event) => { const id = event.params.id - const { rows, err } = query(sql` - SELECT - id, - is_equivalence, - reason, - assumptions, - conclusions, - is_deduced, - dualized_from - FROM category_implications_view - WHERE id = ${id} - `) + const { results, err } = batch<[ImplicationDB, CategoryShort]>([ + sql` + SELECT + id, + is_equivalence, + reason, + assumptions, + conclusions, + is_deduced, + dualized_from + FROM category_implications_view + WHERE id = ${id} + `, + sql` + SELECT c.id, c.name FROM categories c + WHERE EXISTS ( + SELECT 1 FROM category_property_assignments cp + WHERE cp.category_id = c.id + AND cp.reason LIKE '%/category-implication/' || ${id} || '%' + ) + `, + ]) if (err) error(500, 'Could not load implication') - if (!rows.length) error(404, `Could not find implication with ID '${id}'`) + const [implications, categories] = results - const implication: ImplicationDisplay = display_implication(rows[0]) + if (!implications.length) error(404, `Could not find implication with ID '${id}'`) - return render_nested_formulas({ implication }) + const implication: ImplicationDisplay = display_implication(implications[0]) + + return render_nested_formulas({ implication, categories }) } diff --git a/src/routes/category-implication/[id]/+page.svelte b/src/routes/category-implication/[id]/+page.svelte index 1a202aad0..eb40ce10a 100644 --- a/src/routes/category-implication/[id]/+page.svelte +++ b/src/routes/category-implication/[id]/+page.svelte @@ -1,6 +1,8 @@