- Rename namespace/kind to folder/type on entries, audit_log, and history tables; add notes. Unique key is (user_id, folder, name). - Service layer and MCP tools support name-first lookup with optional folder when multiple entries share the same name. - secrets_delete dry_run uses the same disambiguation as real deletes. - Add scripts/migrate-v0.3.0.sql for manual DB migration. Refresh README and AGENTS.md. Made-with: Cursor
24 lines
551 B
Rust
24 lines
551 B
Rust
use anyhow::Result;
|
|
use sqlx::PgPool;
|
|
use uuid::Uuid;
|
|
|
|
use crate::models::AuditLogEntry;
|
|
|
|
pub async fn list_for_user(pool: &PgPool, user_id: Uuid, limit: i64) -> Result<Vec<AuditLogEntry>> {
|
|
let limit = limit.clamp(1, 200);
|
|
|
|
let rows = sqlx::query_as(
|
|
"SELECT id, user_id, action, folder, type, name, detail, created_at \
|
|
FROM audit_log \
|
|
WHERE user_id = $1 \
|
|
ORDER BY created_at DESC, id DESC \
|
|
LIMIT $2",
|
|
)
|
|
.bind(user_id)
|
|
.bind(limit)
|
|
.fetch_all(pool)
|
|
.await?;
|
|
|
|
Ok(rows)
|
|
}
|