Skip to content

Commit 3e76ddd

Browse files
feat(seed): add sample digest entry visible in web Digest section
- Creates a slack_digest_log entry during seed - Shows demo digest content in the Digest tab without Slack - Links to seeded digest preference for consistency - Demonstrates what real digests look like with index recommendations and slow query insights Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
1 parent 0b61bfa commit 3e76ddd

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

‎scripts/self-host/seed-demo-data.sh‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,79 @@ WHERE NOT EXISTS (
755755
SELECT 'Digest preferences seeded' AS status;
756756
EOSQL
757757
echo " Digest preferences created."
758+
759+
# Now create an actual digest entry so it shows in the web UI
760+
echo " Creating sample digest entry (visible in web Digest section)..."
761+
762+
# Get preference ID for linking
763+
pref_id="$(compose exec -T postgres psql -U postgres -d dba_agent -At -c \
764+
"SELECT id FROM digest_preferences WHERE user_id = ${admin_id} AND connection_id = '${connection_id}' LIMIT 1" 2>/dev/null || echo "")"
765+
766+
compose exec -T postgres psql -U postgres -d dba_agent -v ON_ERROR_STOP=1 <<EOSQL
767+
-- Create a sample digest log entry that shows in the web Digest section
768+
-- This is a static demo digest showing what real digests look like
769+
770+
INSERT INTO slack_digest_log (
771+
connection_id, connection_name, channel_id, content, headline,
772+
sent_at, status, recipient_username, recipient_role, persona_tag,
773+
delivery_method, preference_id, personalized
774+
)
775+
SELECT
776+
'${connection_id}',
777+
'${DEEPSQL_SEED_CONNECTION_NAME}',
778+
NULL, -- No Slack channel for web-only display
779+
'*🗄️ DB Health Briefing: ${DEEPSQL_SEED_CONNECTION_NAME}*
780+
_' || TO_CHAR(NOW(), 'FMDay, FMMonth DD') || ' · Quick Wins Ready_
781+
782+
────────────────────────────────
783+
784+
*🔦 Performance Spotlight*
785+
786+
• *3 high-priority index recommendations* ready to apply
787+
- \`idx_orders_status_payment_created\` (orders): 85% estimated improvement
788+
- \`idx_audit_log_table_changed\` (audit_log): Fixes 89s slow queries
789+
- \`idx_products_name_trgm\` (products): Better ILIKE performance
790+
791+
• Top slow query pattern: \`SELECT COUNT(*) FROM orders WHERE LOWER(status) = ...\`
792+
↳ Avg 45ms, called 1.2K times/day — index prevents full scan
793+
794+
────────────────────────────────
795+
796+
*🎯 Quick Wins*
797+
798+
• *CREATE INDEX idx_orders_status_payment_created* — Estimated 38s daily savings
799+
• Review audit_log growth (50K+ rows, missing index on changed_at)
800+
• Consider trigram index for product search ILIKE patterns
801+
802+
────────────────────────────────
803+
804+
*📈 Brain Intelligence*
805+
806+
• Workload analysis complete — 7 distinct query patterns identified
807+
• Database health score: Pending initial assessment
808+
• 5 curated schema notes ready for review
809+
810+
────────────────────────────────
811+
812+
_Powered by DeepSQL · This digest runs daily at 9:00 AM_',
813+
'Quick Wins Ready',
814+
NOW(),
815+
'SENT',
816+
'${DEEPSQL_INITIAL_ADMIN_EMAIL}',
817+
'ADMIN',
818+
'DBA',
819+
'SLACK_DM',
820+
${pref_id:-NULL},
821+
true
822+
WHERE NOT EXISTS (
823+
SELECT 1 FROM slack_digest_log
824+
WHERE connection_id = '${connection_id}'
825+
AND recipient_username = '${DEEPSQL_INITIAL_ADMIN_EMAIL}'
826+
);
827+
828+
SELECT 'Sample digest entry created' AS status;
829+
EOSQL
830+
echo " Sample digest entry created."
758831
else
759832
echo " Skipping digest preferences (missing connection or admin ID)"
760833
fi

0 commit comments

Comments
 (0)