summaryrefslogtreecommitdiff
path: root/makima/src/db
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-04-28 19:12:52 +0100
committerGitHub <noreply@github.com>2026-04-28 19:12:52 +0100
commitd1fdfb140cc440664f77a24886172f9976a05a31 (patch)
tree454739f80dde60fc6c1cd97acbaef3223ac041c6 /makima/src/db
parent636694182fe9381479f2e9062229dda3838c5421 (diff)
downloadsoryu-d1fdfb140cc440664f77a24886172f9976a05a31.tar.gz
soryu-d1fdfb140cc440664f77a24886172f9976a05a31.zip
feat: revert broken directive PRs, re-implement Lexical document orchestrator (#98)
* feat: soryu-co/soryu - makima: Revert broken directive PRs and verify clean build * feat: soryu-co/soryu - makima: Re-implement frontend: Lexical document editor with feature flag and base components * WIP: heartbeat checkpoint * feat: soryu-co/soryu - makima: Add contract blocks, expandable log rows, and interaction controls * WIP: heartbeat checkpoint * feat: soryu-co/soryu - makima: End-to-end build verification and integration polish
Diffstat (limited to 'makima/src/db')
-rw-r--r--makima/src/db/models.rs12
-rw-r--r--makima/src/db/repository.rs20
2 files changed, 19 insertions, 13 deletions
diff --git a/makima/src/db/models.rs b/makima/src/db/models.rs
index 121897d..c11150f 100644
--- a/makima/src/db/models.rs
+++ b/makima/src/db/models.rs
@@ -7,7 +7,6 @@ use utoipa::ToSchema;
use uuid::Uuid;
/// Default max retries for task daemon failover (3 attempts)
-#[allow(dead_code)]
fn default_max_retries() -> i32 {
3
}
@@ -3051,19 +3050,24 @@ pub struct DirectiveOrderGroupListResponse {
pub total: i64,
}
-/// User setting record from the database (key-value per owner).
+// =============================================================================
+// User Settings Types
+// =============================================================================
+
+/// A user setting (feature flag / preference) stored in the database.
#[derive(Debug, Clone, FromRow, Serialize, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct UserSetting {
pub id: Uuid,
pub owner_id: Uuid,
pub key: String,
+ #[sqlx(json)]
pub value: serde_json::Value,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}
-/// Request body for upserting a user setting.
+/// Request to upsert (create or update) a user setting.
#[derive(Debug, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct UpsertUserSettingRequest {
@@ -3071,7 +3075,7 @@ pub struct UpsertUserSettingRequest {
pub value: serde_json::Value,
}
-/// Response containing a list of user settings.
+/// Response wrapping a list of user settings.
#[derive(Debug, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct UserSettingsResponse {
diff --git a/makima/src/db/repository.rs b/makima/src/db/repository.rs
index 10633d5..5a912e4 100644
--- a/makima/src/db/repository.rs
+++ b/makima/src/db/repository.rs
@@ -21,7 +21,6 @@ use super::models::{
PhaseDefinition, SupervisorHeartbeatRecord, SupervisorState,
Task, TaskCheckpoint, TaskEvent, TaskSummary, UpdateContractRequest,
UpdateFileRequest, UpdateTaskRequest, UpdateTemplateRequest,
- UserSetting,
};
/// Repository error types.
@@ -4912,7 +4911,6 @@ pub async fn sync_supervisor_state(
// =============================================================================
/// Helper to truncate string to max length
-#[allow(dead_code)]
fn truncate_string(s: &str, max_len: usize) -> String {
if s.len() <= max_len {
s.to_string()
@@ -6700,9 +6698,11 @@ pub async fn get_available_orders_for_dog_pickup(
.await
}
-// ─── User Settings ───────────────────────────────────────────────────────────
+// =============================================================================
+// User Settings
+// =============================================================================
-/// Get all settings for a given owner.
+/// Get all settings for a user.
pub async fn get_user_settings(
pool: &PgPool,
owner_id: Uuid,
@@ -6720,7 +6720,7 @@ pub async fn get_user_settings(
.await
}
-/// Get a single setting by owner and key.
+/// Get a specific setting by key for a user.
pub async fn get_user_setting(
pool: &PgPool,
owner_id: Uuid,
@@ -6739,7 +6739,7 @@ pub async fn get_user_setting(
.await
}
-/// Upsert a user setting (insert or update on conflict).
+/// Upsert (create or update) a user setting.
pub async fn upsert_user_setting(
pool: &PgPool,
owner_id: Uuid,
@@ -6750,8 +6750,9 @@ pub async fn upsert_user_setting(
r#"
INSERT INTO user_settings (owner_id, key, value)
VALUES ($1, $2, $3)
- ON CONFLICT (owner_id, key) DO UPDATE
- SET value = EXCLUDED.value, updated_at = now()
+ ON CONFLICT (owner_id, key) DO UPDATE SET
+ value = EXCLUDED.value,
+ updated_at = NOW()
RETURNING id, owner_id, key, value, created_at, updated_at
"#,
)
@@ -6762,7 +6763,7 @@ pub async fn upsert_user_setting(
.await
}
-/// Delete a user setting. Returns true if a row was deleted.
+/// Delete a user setting by key. Returns true if a row was deleted.
pub async fn delete_user_setting(
pool: &PgPool,
owner_id: Uuid,
@@ -6778,6 +6779,7 @@ pub async fn delete_user_setting(
.bind(key)
.execute(pool)
.await?;
+
Ok(result.rows_affected() > 0)
}