From af9db0e50d7b28259a370149a3631a2c91cecfd4 Mon Sep 17 00:00:00 2001 From: TheGeneralist <180094941+thegeneralist01@users.noreply.github.com> Date: Sun, 19 Jul 2026 10:56:59 +0200 Subject: [PATCH] feat(tags): slugify_segment, move_tag, entry_count, subtree_count, /move API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Extract slugify_segment() from rename_tag and apply it in create_tag_path so new tags get proper slug normalization (spaces→hyphens, strip non-alphanumeric, collapse runs, trim edges) instead of raw input - Add move_tag(conn, tag_uid, new_parent_uid) to database.rs: * transactional: updates parent_tag_id then cascades full_path to the entire subtree via a recursive CTE (same pattern as rename_tag) * rejects self-move, descendant-move, and path collisions * None parent_uid promotes the tag to root - Fix cascade SQL in both rename_tag and move_tag: use prefix-anchored substr instead of REPLACE to avoid corrupting paths where the old prefix slug reappears at a non-overlapping position - Add entry_count: i64 to TagNode (direct assignments per tag) - Add subtree_count: i64 to TagNode (unique entries on tag or any descendant via recursive CTE + COUNT(DISTINCT)); COUNT(DISTINCT) ensures an entry tagged at both a parent and a child counts once - Add POST /api/archives/:id/tags/:uid/move with MoveTagBody { parent_uid } (null = root; dedicated route so no Option