- Introduced a global search button and modal for enhanced user experience. - Added a new section for displaying email results in the global search modal. - Implemented functionality to fetch and display emails based on user queries. - Updated the UI to include a reminders button and improved accessibility features. fix: Update docker-compose to allow reload configuration - Changed ENABLE_RELOAD environment variable to default to true for easier development. chore: Update requirements for new dependencies - Added brother_ql, pyzbar, and pypdfium2 to requirements for label printing and PDF processing. feat: Implement Brother label printing service - Created a new service for printing labels using Brother QL printers. - Supports direct printing of case hardware labels with customizable layouts. feat: Add Vaultwarden service for credential management - Implemented a service to interact with Vaultwarden for secure credential storage and retrieval. sql: Add migrations for email thread keys and document tokens - Created migrations to backfill email thread keys and manage document tokens for work orders. - Introduced new tables and updated existing structures to support token-based linking of scanned documents. sql: Import links into the database - Added a script to import a predefined set of links into the database with associated categories.
21 lines
614 B
SQL
21 lines
614 B
SQL
-- Check thread fragmentation per SAG
|
|
WITH resolved AS (
|
|
SELECT
|
|
se.sag_id,
|
|
em.id,
|
|
em.thread_key,
|
|
em.folder,
|
|
COALESCE(
|
|
NULLIF(REGEXP_REPLACE(TRIM(COALESCE(em.thread_key, '')), '[<>\s]', '', 'g'), ''),
|
|
CONCAT('email-', em.id::text)
|
|
) AS resolved_key
|
|
FROM sag_emails se
|
|
JOIN email_messages em ON em.id = se.email_id
|
|
WHERE em.deleted_at IS NULL
|
|
)
|
|
SELECT sag_id, COUNT(DISTINCT resolved_key) as thread_count, COUNT(*) as email_count
|
|
FROM resolved
|
|
GROUP BY sag_id
|
|
HAVING COUNT(DISTINCT resolved_key) > 1
|
|
ORDER BY thread_count DESC;
|