refactor(db): name audit entity_type constants for vocab/term/authority (#21)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,8 @@ use sqlx::Row;
|
|||||||
|
|
||||||
use crate::audit;
|
use crate::audit;
|
||||||
|
|
||||||
|
const AUTHORITY_ENTITY_TYPE: &str = "authority";
|
||||||
|
|
||||||
/// Labels aggregated per row as JSON, to read an authority and its labels in one query.
|
/// Labels aggregated per row as JSON, to read an authority and its labels in one query.
|
||||||
const LABELS_JSON: &str = "COALESCE(json_agg(json_build_object('lang', al.lang, 'label', al.label) \
|
const LABELS_JSON: &str = "COALESCE(json_agg(json_build_object('lang', al.lang, 'label', al.label) \
|
||||||
ORDER BY al.lang) FILTER (WHERE al.authority_id IS NOT NULL), '[]'::json)";
|
ORDER BY al.lang) FILTER (WHERE al.authority_id IS NOT NULL), '[]'::json)";
|
||||||
@@ -43,7 +45,7 @@ pub async fn create_authority(
|
|||||||
&NewAuditEvent {
|
&NewAuditEvent {
|
||||||
actor,
|
actor,
|
||||||
action: AuditAction::Created,
|
action: AuditAction::Created,
|
||||||
entity_type: "authority".to_owned(),
|
entity_type: AUTHORITY_ENTITY_TYPE.to_owned(),
|
||||||
entity_id: id.to_uuid(),
|
entity_id: id.to_uuid(),
|
||||||
changes: Vec::new(),
|
changes: Vec::new(),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ use sqlx::Row;
|
|||||||
|
|
||||||
use crate::audit;
|
use crate::audit;
|
||||||
|
|
||||||
|
const VOCABULARY_ENTITY_TYPE: &str = "vocabulary";
|
||||||
|
const TERM_ENTITY_TYPE: &str = "term";
|
||||||
|
|
||||||
/// Labels aggregated per row as JSON, to read a term and its labels in one query.
|
/// Labels aggregated per row as JSON, to read a term and its labels in one query.
|
||||||
const LABELS_JSON: &str = "COALESCE(json_agg(json_build_object('lang', tl.lang, 'label', tl.label) \
|
const LABELS_JSON: &str = "COALESCE(json_agg(json_build_object('lang', tl.lang, 'label', tl.label) \
|
||||||
ORDER BY tl.lang) FILTER (WHERE tl.term_id IS NOT NULL), '[]'::json)";
|
ORDER BY tl.lang) FILTER (WHERE tl.term_id IS NOT NULL), '[]'::json)";
|
||||||
@@ -32,7 +35,7 @@ pub async fn create_vocabulary(
|
|||||||
&NewAuditEvent {
|
&NewAuditEvent {
|
||||||
actor,
|
actor,
|
||||||
action: AuditAction::Created,
|
action: AuditAction::Created,
|
||||||
entity_type: "vocabulary".to_owned(),
|
entity_type: VOCABULARY_ENTITY_TYPE.to_owned(),
|
||||||
entity_id: id.to_uuid(),
|
entity_id: id.to_uuid(),
|
||||||
changes: Vec::new(),
|
changes: Vec::new(),
|
||||||
},
|
},
|
||||||
@@ -104,7 +107,7 @@ pub async fn add_term(
|
|||||||
&NewAuditEvent {
|
&NewAuditEvent {
|
||||||
actor,
|
actor,
|
||||||
action: AuditAction::Created,
|
action: AuditAction::Created,
|
||||||
entity_type: "term".to_owned(),
|
entity_type: TERM_ENTITY_TYPE.to_owned(),
|
||||||
entity_id: id.to_uuid(),
|
entity_id: id.to_uuid(),
|
||||||
changes: Vec::new(),
|
changes: Vec::new(),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user