The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
## Content Diagnostics — detected findings snapshot (scan-snapshot, latest-wins).
## Persisted table: `content_diagnostics_finding`.
##
## `entity_name` and `entity_creator_name` carry no index: both sort through `lower()`, which a plain B-tree
## can't serve. `scan_id` has no index of its own: its only predicate is a `!=`, and it leads
## `idx_uniq_cd_finding`. `idx_cd_finding_detected` serves `last-detected-at` (an unfiltered
## `ORDER BY detected_at DESC LIMIT 1` on every list request) and the default sort.
##
## Every changeset is marked ran when its object already exists.
databaseChangeLog:
- changeSet:
id: v65.pux7zh
author: yb
comment: Content Diagnostics — content_diagnostics_finding (scan snapshot)
preConditions:
- onFail: MARK_RAN
- not:
- tableExists:
tableName: content_diagnostics_finding
changes:
- createTable:
tableName: content_diagnostics_finding
remarks: One detected problem for one entity, from one scan run.
columns:
- column:
name: id
type: int
autoIncrement: true
constraints:
primaryKey: true
nullable: false
- column:
name: scan_id
type: varchar(36)
remarks: Groups all rows from one scan run (UUID). API serves the newest scan.
constraints:
nullable: false
- column:
name: entity_type
type: varchar(32)
remarks: Polymorphic — card/dashboard/document/collection/transform. No FK.
constraints:
nullable: false
- column:
name: entity_id
type: int
remarks: Polymorphic id of the flagged entity (no FK; paired with entity_type).
constraints:
nullable: false
- column:
name: finding_type
type: varchar(32)
remarks: stale/duplicated/empty/crowded/sparse/slow/trash-not-emptied
constraints:
nullable: false
- column:
name: scope_collection_id
type: int
remarks: collection the entity lived in at scan time (filter/sort); no FK
- column:
name: details
type: ${text.type}
remarks: JSON evidence — e.g. {threshold_days, last_active_at}
- column:
name: detected_at
type: ${timestamp_type}
defaultValueComputed: current_timestamp
remarks: When this finding was detected (per-finding freshness signal).
constraints:
nullable: false
- column:
name: invalidated_at
type: ${timestamp_type}
remarks: stamped when invalidated/superseded; null = active (drives the served-set filter)
- column:
name: last_active_at
type: ${timestamp_type}
remarks: Entity's last activity at scan time (card last_used_at / dashboard last_viewed_at); null = never used/ran. Frozen verdict evidence; powers the threshold-days serve filter.
- column:
name: entity_name
type: ${text.type}
remarks: Entity's name at scan time; served as entity_display_name and used as the sort/search key. text because upstream names are unbounded.
- column:
name: entity_created_at
type: ${timestamp_type}
remarks: Entity's created_at (immutable). Denormalized for sort + display.
- column:
name: entity_creator_id
type: int
remarks: Entity's creator_id at scan time; no FK (polymorphic, mirrors entity_id). Sort key (groups by creator).
- column:
name: entity_creator_name
type: ${text.type}
remarks: Creator's common_name at scan time (resolved from creator_id). Sort key for created-by, served in details.creator. text because common_name can be an email, which is unbounded on Postgres.
- column:
name: duration_ms
type: bigint
remarks: Verdict magnitude for slow findings - median query ms (card) / last-run ms (transform) / slowest-child ms (dashboard/document roll-up); null on all other finding types (per-type named magnitude column). bigint, not int - a pathological run duration can exceed 2^31-1 ms.
- column:
name: content_count
type: bigint
remarks: Verdict magnitude for imbalanced (empty/sparse/crowded) findings - items (collection) / dashcards or tabs (dashboard) / cards (document) / rows (card, transform); 0 on every empty finding, null on all other finding types (per-type named magnitude column). bigint - house choice for magnitude columns.
- column:
name: duplicate_count
type: bigint
remarks: Verdict magnitude for duplicated findings - the number of other same-type entities sharing the normalized name (cluster size minus 1); null on all other finding types (per-type named magnitude column).
- column:
name: card_type
type: varchar(32)
remarks: report_card.type (question/model/metric) at scan time, card findings only; null on all other entity types. Denormalized filter key for the card sub-kind values of the entity-types param (mutable upstream - drift until the next scan, like entity_name).
- column:
name: entity_collection_name
type: ${text.type}
remarks: Scan-time name of the scope_collection_id collection (root rows store the root label); sort/display value for the collection column.
- column:
name: entity_kind
type: varchar(32)
remarks: Flat entity kind at scan time - card_type for cards, else entity_type; serves the entity-types filter and entity-type sort.
- changeSet:
id: v65.jmeicl
author: yb
comment: Content Diagnostics — unique finding per scan (dedup)
preConditions:
- onFail: MARK_RAN
- not:
# MySQL/MariaDB implement the constraint as an index of the same name, which uniqueConstraintExists misses
- or:
- uniqueConstraintExists:
tableName: content_diagnostics_finding
constraintName: idx_uniq_cd_finding
- indexExists:
tableName: content_diagnostics_finding
indexName: idx_uniq_cd_finding
changes:
- addUniqueConstraint:
tableName: content_diagnostics_finding
columnNames: scan_id, entity_type, entity_id, finding_type
constraintName: idx_uniq_cd_finding
- changeSet:
id: v65.3ynvmr
author: yb
comment: Content Diagnostics — index findings by entity
preConditions:
- onFail: MARK_RAN
- not:
- indexExists:
tableName: content_diagnostics_finding
indexName: idx_cd_finding_entity
changes:
- createIndex:
tableName: content_diagnostics_finding
indexName: idx_cd_finding_entity
columns:
- column:
name: entity_type
- column:
name: entity_id
- changeSet:
id: v65.qznubo
author: yb
comment: Content Diagnostics — index findings by detected_at
preConditions:
- onFail: MARK_RAN
- not:
- indexExists:
tableName: content_diagnostics_finding
indexName: idx_cd_finding_detected
changes:
- createIndex:
tableName: content_diagnostics_finding
indexName: idx_cd_finding_detected
columns:
- column:
name: detected_at
- changeSet:
id: v65.9pq42l
author: yb
comment: Content Diagnostics — index findings by finding_type + entity_created_at
preConditions:
- onFail: MARK_RAN
- not:
- indexExists:
tableName: content_diagnostics_finding
indexName: idx_cd_finding_ftype_created
changes:
- createIndex:
tableName: content_diagnostics_finding
indexName: idx_cd_finding_ftype_created
columns:
- column:
name: finding_type
- column:
name: entity_created_at
- changeSet:
id: v65.xy6d2y
author: yb
comment: Content Diagnostics — index findings by finding_type + last_active_at
preConditions:
- onFail: MARK_RAN
- not:
- indexExists:
tableName: content_diagnostics_finding
indexName: idx_cd_finding_ftype_active
changes:
- createIndex:
tableName: content_diagnostics_finding
indexName: idx_cd_finding_ftype_active
columns:
- column:
name: finding_type
- column:
name: last_active_at
- changeSet:
id: v65.5hg5yl
author: yb
comment: Content Diagnostics — index findings by finding_type + duration_ms
preConditions:
- onFail: MARK_RAN
- not:
- indexExists:
tableName: content_diagnostics_finding
indexName: idx_cd_finding_ftype_duration
changes:
- createIndex:
tableName: content_diagnostics_finding
indexName: idx_cd_finding_ftype_duration
columns:
- column:
name: finding_type
- column:
name: duration_ms
- changeSet:
id: v65.1l7sd5
author: yb
comment: Content Diagnostics — index findings by finding_type + content_count
preConditions:
- onFail: MARK_RAN
- not:
- indexExists:
tableName: content_diagnostics_finding
indexName: idx_cd_finding_ftype_content_count
changes:
- createIndex:
tableName: content_diagnostics_finding
indexName: idx_cd_finding_ftype_content_count
columns:
- column:
name: finding_type
- column:
name: content_count
- changeSet:
id: v65.2bp272
author: yb
comment: Content Diagnostics — index findings by finding_type + duplicate_count
preConditions:
- onFail: MARK_RAN
- not:
- indexExists:
tableName: content_diagnostics_finding
indexName: idx_cd_finding_ftype_duplicate_count
changes:
- createIndex:
tableName: content_diagnostics_finding
indexName: idx_cd_finding_ftype_duplicate_count
columns:
- column:
name: finding_type
- column:
name: duplicate_count
- changeSet:
id: v65.i4ropf
author: yb
comment: Content Diagnostics — index for the entity-types filter and entity-type sort
preConditions:
- onFail: MARK_RAN
- not:
- indexExists:
tableName: content_diagnostics_finding
indexName: idx_cd_finding_ftype_entity_kind
changes:
- createIndex:
tableName: content_diagnostics_finding
indexName: idx_cd_finding_ftype_entity_kind
columns:
- column:
name: finding_type
- column:
name: entity_kind
- changeSet:
id: v65.mmndvn
author: yb
comment: Content Diagnostics — index findings by invalidated_at
preConditions:
- onFail: MARK_RAN
- not:
- indexExists:
tableName: content_diagnostics_finding
indexName: idx_cd_finding_invalidated
changes:
- createIndex:
tableName: content_diagnostics_finding
indexName: idx_cd_finding_invalidated
columns:
- column:
name: invalidated_at