Skip to content

Commit

Permalink
feat: added description and comment
Browse files Browse the repository at this point in the history
  • Loading branch information
sauraww committed Dec 18, 2024
1 parent f4301d8 commit fb60179
Show file tree
Hide file tree
Showing 63 changed files with 985 additions and 119 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ALTER TABLE public.config_versions DROP COLUMN IF EXISTS description;
ALTER TABLE public.config_versions DROP COLUMN IF EXISTS change_reason;

ALTER TABLE public.functions ALTER COLUMN description DROP NOT NULL;
ALTER TABLE public.functions ALTER COLUMN description DROP DEFAULT;
ALTER TABLE public.functions DROP COLUMN IF EXISTS change_reason;

ALTER TABLE public.functions RENAME COLUMN description TO function_description;

ALTER TABLE public.type_templates DROP COLUMN IF EXISTS description;
ALTER TABLE public.type_templates DROP COLUMN IF EXISTS change_reason;

ALTER TABLE public.default_configs DROP COLUMN IF EXISTS description;
ALTER TABLE public.default_configs DROP COLUMN IF EXISTS change_reason;

ALTER TABLE public.dimensions DROP COLUMN IF EXISTS description;
ALTER TABLE public.dimensions DROP COLUMN IF EXISTS change_reason;

ALTER TABLE public.contexts DROP COLUMN IF EXISTS description;
ALTER TABLE public.contexts DROP COLUMN IF EXISTS change_reason;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

ALTER TABLE public.contexts ADD COLUMN IF NOT EXISTS description TEXT DEFAULT '' NOT NULL;
ALTER TABLE public.contexts ADD COLUMN IF NOT EXISTS change_reason TEXT DEFAULT '' NOT NULL;

ALTER TABLE public.dimensions ADD COLUMN IF NOT EXISTS description TEXT DEFAULT '' NOT NULL;
ALTER TABLE public.dimensions ADD COLUMN IF NOT EXISTS change_reason TEXT DEFAULT '' NOT NULL;

ALTER TABLE public.default_configs ADD COLUMN IF NOT EXISTS description TEXT DEFAULT '' NOT NULL;
ALTER TABLE public.default_configs ADD COLUMN IF NOT EXISTS change_reason TEXT DEFAULT '' NOT NULL;

ALTER TABLE public.type_templates ADD COLUMN IF NOT EXISTS description TEXT DEFAULT '' NOT NULL;
ALTER TABLE public.type_templates ADD COLUMN IF NOT EXISTS change_reason TEXT DEFAULT '' NOT NULL;

ALTER TABLE public.functions RENAME COLUMN function_description TO description;
ALTER TABLE public.functions ADD COLUMN IF NOT EXISTS change_reason TEXT DEFAULT '' NOT NULL;

ALTER TABLE public.functions ALTER COLUMN description SET DEFAULT '';
ALTER TABLE public.functions ALTER COLUMN description SET NOT NULL;

ALTER TABLE public.config_versions ADD COLUMN IF NOT EXISTS description TEXT DEFAULT '' NOT NULL;
ALTER TABLE public.config_versions ADD COLUMN IF NOT EXISTS change_reason TEXT DEFAULT '' NOT NULL;
27 changes: 24 additions & 3 deletions crates/context_aware_config/src/api/config/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,31 @@ fn construct_new_payload(
},
)?;

return Ok(web::Json(PutReq {
context: context,
let description = match res.get("description") {
Some(Value::String(s)) => Some(s.clone()),
Some(_) => {
log::error!("construct new payload: Description is not a valid string");
return Err(bad_argument!("Description must be a string"));
}
None => None,
};

// Handle change_reason
let change_reason = res
.get("change_reason")
.and_then(|val| val.as_str())
.map(|s| s.to_string())
.ok_or_else(|| {
log::error!("construct new payload: Change reason not present or invalid");
bad_argument!("Change reason is required and must be a string")
})?;

Ok(web::Json(PutReq {
context,
r#override: override_,
}));
description,
change_reason,
}))
}

#[allow(clippy::too_many_arguments)]
Expand Down
Loading

0 comments on commit fb60179

Please sign in to comment.