removing recomputation
This commit is contained in:
2
client
2
client
Submodule client updated: 7a63161ad8...71b5cff16d
@@ -157,10 +157,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
".komp_ac.table_definition.ColumnDefinition",
|
||||
"#[derive(serde::Serialize, serde::Deserialize)]",
|
||||
)
|
||||
.field_attribute(
|
||||
".komp_ac.table_definition.ColumnDefinition.recompute_on_dependency_change",
|
||||
"#[serde(default)]",
|
||||
)
|
||||
.type_attribute(
|
||||
".komp_ac.table_definition.TableLink",
|
||||
"#[derive(serde::Serialize, serde::Deserialize)]"
|
||||
|
||||
@@ -197,9 +197,7 @@ message ColumnDefinition {
|
||||
// MONEY rounding applied before a value is stored.
|
||||
MoneyRounding rounding = 4;
|
||||
|
||||
// When true, the submitted script result is validated normally and the
|
||||
// stored value is also refreshed when one of its dependencies later changes.
|
||||
bool recompute_on_dependency_change = 5;
|
||||
reserved 5;
|
||||
}
|
||||
|
||||
// Response after table creation (success + DDL preview).
|
||||
|
||||
@@ -167,8 +167,7 @@ message StoredTableScript {
|
||||
string description = 5;
|
||||
// Complete allowlist of data inputs that may be exposed to this script.
|
||||
repeated ScriptDependency dependencies = 6;
|
||||
// Whether changes to dependency rows trigger authoritative server propagation.
|
||||
bool recompute_on_dependency_change = 7;
|
||||
reserved 7;
|
||||
}
|
||||
|
||||
message ScriptDependency {
|
||||
|
||||
@@ -75,7 +75,7 @@ message TableColumn {
|
||||
|
||||
// True for a user-defined column whose logic should be recomputed whenever
|
||||
// one of its dependencies changes. False for system and foreign-key columns.
|
||||
bool recompute_on_dependency_change = 5;
|
||||
reserved 5;
|
||||
|
||||
// True when the server created this as a companion of another logical column.
|
||||
bool generated = 6;
|
||||
|
||||
@@ -137,8 +137,7 @@ message PostTableDataResponse {
|
||||
// The id of the inserted row.
|
||||
int64 inserted_id = 3;
|
||||
|
||||
// Rows whose stored script values changed through dependency propagation.
|
||||
repeated RecomputedRow recomputed_rows = 4;
|
||||
reserved 4;
|
||||
|
||||
// Revision committed for the inserted row.
|
||||
int64 row_revision = 5;
|
||||
@@ -213,19 +212,12 @@ message PutTableDataResponse {
|
||||
// The id of the updated row.
|
||||
int64 updated_id = 3;
|
||||
|
||||
// Rows whose stored script values changed through dependency propagation.
|
||||
repeated RecomputedRow recomputed_rows = 4;
|
||||
reserved 4;
|
||||
|
||||
// Revision committed for the updated row.
|
||||
int64 row_revision = 5;
|
||||
}
|
||||
|
||||
message RecomputedRow {
|
||||
string table_name = 1;
|
||||
int64 row_id = 2;
|
||||
int64 row_revision = 3;
|
||||
}
|
||||
|
||||
// Soft-delete a single row.
|
||||
message DeleteTableDataRequest {
|
||||
// Required. Profile (schema) name.
|
||||
@@ -246,8 +238,7 @@ message DeleteTableDataResponse {
|
||||
// True if a row was marked deleted (id existed and was not already deleted).
|
||||
bool success = 1;
|
||||
|
||||
// Rows whose stored script values changed through dependency propagation.
|
||||
repeated RecomputedRow recomputed_rows = 2;
|
||||
reserved 2;
|
||||
}
|
||||
|
||||
// Fetch a single non-deleted row by id.
|
||||
|
||||
Binary file not shown.
@@ -166,11 +166,6 @@ pub struct ColumnDefinition {
|
||||
/// MONEY rounding applied before a value is stored.
|
||||
#[prost(enumeration = "MoneyRounding", tag = "4")]
|
||||
pub rounding: i32,
|
||||
/// When true, the submitted script result is validated normally and the
|
||||
/// stored value is also refreshed when one of its dependencies later changes.
|
||||
#[prost(bool, tag = "5")]
|
||||
#[serde(default)]
|
||||
pub recompute_on_dependency_change: bool,
|
||||
}
|
||||
/// Response after table creation (success + DDL preview).
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
|
||||
@@ -108,9 +108,6 @@ pub struct StoredTableScript {
|
||||
/// Complete allowlist of data inputs that may be exposed to this script.
|
||||
#[prost(message, repeated, tag = "6")]
|
||||
pub dependencies: ::prost::alloc::vec::Vec<ScriptDependency>,
|
||||
/// Whether changes to dependency rows trigger authoritative server propagation.
|
||||
#[prost(bool, tag = "7")]
|
||||
pub recompute_on_dependency_change: bool,
|
||||
}
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct ScriptDependency {
|
||||
|
||||
@@ -55,10 +55,6 @@ pub struct TableColumn {
|
||||
/// Typically true for the "id" column created by the system.
|
||||
#[prost(bool, tag = "4")]
|
||||
pub is_primary_key: bool,
|
||||
/// True for a user-defined column whose logic should be recomputed whenever
|
||||
/// one of its dependencies changes. False for system and foreign-key columns.
|
||||
#[prost(bool, tag = "5")]
|
||||
pub recompute_on_dependency_change: bool,
|
||||
/// True when the server created this as a companion of another logical column.
|
||||
#[prost(bool, tag = "6")]
|
||||
pub generated: bool,
|
||||
|
||||
@@ -48,7 +48,7 @@ pub struct PostTableDataRequest {
|
||||
>,
|
||||
}
|
||||
/// Insert response.
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct PostTableDataResponse {
|
||||
/// True if the insert succeeded.
|
||||
#[prost(bool, tag = "1")]
|
||||
@@ -59,9 +59,6 @@ pub struct PostTableDataResponse {
|
||||
/// The id of the inserted row.
|
||||
#[prost(int64, tag = "3")]
|
||||
pub inserted_id: i64,
|
||||
/// Rows whose stored script values changed through dependency propagation.
|
||||
#[prost(message, repeated, tag = "4")]
|
||||
pub recomputed_rows: ::prost::alloc::vec::Vec<RecomputedRow>,
|
||||
/// Revision committed for the inserted row.
|
||||
#[prost(int64, tag = "5")]
|
||||
pub row_revision: i64,
|
||||
@@ -135,7 +132,7 @@ pub struct PutTableDataRequest {
|
||||
pub expected_revision: i64,
|
||||
}
|
||||
/// Update response.
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct PutTableDataResponse {
|
||||
/// True if the update succeeded (or no-op on empty data).
|
||||
#[prost(bool, tag = "1")]
|
||||
@@ -146,22 +143,10 @@ pub struct PutTableDataResponse {
|
||||
/// The id of the updated row.
|
||||
#[prost(int64, tag = "3")]
|
||||
pub updated_id: i64,
|
||||
/// Rows whose stored script values changed through dependency propagation.
|
||||
#[prost(message, repeated, tag = "4")]
|
||||
pub recomputed_rows: ::prost::alloc::vec::Vec<RecomputedRow>,
|
||||
/// Revision committed for the updated row.
|
||||
#[prost(int64, tag = "5")]
|
||||
pub row_revision: i64,
|
||||
}
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct RecomputedRow {
|
||||
#[prost(string, tag = "1")]
|
||||
pub table_name: ::prost::alloc::string::String,
|
||||
#[prost(int64, tag = "2")]
|
||||
pub row_id: i64,
|
||||
#[prost(int64, tag = "3")]
|
||||
pub row_revision: i64,
|
||||
}
|
||||
/// Soft-delete a single row.
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct DeleteTableDataRequest {
|
||||
@@ -179,14 +164,11 @@ pub struct DeleteTableDataRequest {
|
||||
pub expected_revision: i64,
|
||||
}
|
||||
/// Soft-delete response.
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct DeleteTableDataResponse {
|
||||
/// True if a row was marked deleted (id existed and was not already deleted).
|
||||
#[prost(bool, tag = "1")]
|
||||
pub success: bool,
|
||||
/// Rows whose stored script values changed through dependency propagation.
|
||||
#[prost(message, repeated, tag = "2")]
|
||||
pub recomputed_rows: ::prost::alloc::vec::Vec<RecomputedRow>,
|
||||
}
|
||||
/// Fetch a single non-deleted row by id.
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
|
||||
@@ -74,7 +74,6 @@ impl CreateTableForm {
|
||||
name: name.to_string(),
|
||||
field_type: field_type.to_string(),
|
||||
rounding: rounding.into(),
|
||||
recompute_on_dependency_change: flags.contains(&"recompute"),
|
||||
});
|
||||
}
|
||||
if columns.is_empty() {
|
||||
@@ -144,7 +143,7 @@ mod tests {
|
||||
let request = CreateTableForm {
|
||||
profile_name: "accounting".into(),
|
||||
table_name: "invoice".into(),
|
||||
columns: "number: text:indexed\namount: money:half-up,recompute".into(),
|
||||
columns: "number: text:indexed\namount: money:half-up".into(),
|
||||
required_links: "customer".into(),
|
||||
base_currency: "eur".into(),
|
||||
row_display_columns: "number, amount".into(),
|
||||
@@ -158,6 +157,5 @@ mod tests {
|
||||
assert!(request.links[0].required);
|
||||
assert_eq!(request.base_currency, "EUR");
|
||||
assert_eq!(request.row_display_columns, vec!["number", "amount"]);
|
||||
assert!(request.columns[1].recompute_on_dependency_change);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ pub(crate) fn render_page(page: &AddTablePageState) -> String {
|
||||
.map(render_submission_error)
|
||||
.unwrap_or_default();
|
||||
format!(
|
||||
"<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><title>Add table</title><script src=\"https://cdn.jsdelivr.net/npm/htmx.org@2/dist/htmx.min.js\"></script><style>{ADMIN_CSS}</style></head><body><header class=\"topbar\"><div><strong>Komp Accounting</strong></div><nav><a href=\"/admin\">Admin</a><a href=\"/\">Analytics</a></nav></header><main class=\"form-main\"><a class=\"back-link\" href=\"/admin\">← Admin panel</a><section class=\"form-card\"><p class=\"eyebrow\">Table definition</p><h1>Add table</h1><p>Create a table through the existing gRPC table-definition service.</p><form hx-post=\"/admin/tables\" hx-target=\"#submission-status\" hx-swap=\"innerHTML\" hx-disabled-elt=\"button[type=submit]\"><div class=\"form-grid\"><label>Profile<select name=\"profile_name\" required><option value=\"\">Choose a profile</option>{options}</select></label><label>Table name<input name=\"table_name\" value=\"{}\" required placeholder=\"invoices\"></label><label class=\"wide\">Columns<textarea name=\"columns\" rows=\"9\" required placeholder=\"number: text:indexed issued_on: date amount: money:half-up,recompute\">{}</textarea><small>One per line: <code>name: type: optional flags</code>. Flags: indexed, half-up, recompute.</small></label><label>Additional indexed columns<input name=\"indexed_columns\" value=\"{}\" placeholder=\"number, issued_on\"></label><label>Base currency<input name=\"base_currency\" value=\"{}\" maxlength=\"3\" placeholder=\"EUR\"></label><label>Required links<input name=\"required_links\" value=\"{}\" placeholder=\"customer, address\"></label><label>Optional links<input name=\"optional_links\" value=\"{}\" placeholder=\"project\"></label><label>Row display columns<input name=\"row_display_columns\" value=\"{}\" placeholder=\"name, ico\"></label></div><div id=\"submission-status\" aria-live=\"polite\">{error}</div><div class=\"form-actions\"><a href=\"/admin\">Cancel</a><button type=\"submit\">Create table</button></div></form></section></main></body></html>",
|
||||
"<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><title>Add table</title><script src=\"https://cdn.jsdelivr.net/npm/htmx.org@2/dist/htmx.min.js\"></script><style>{ADMIN_CSS}</style></head><body><header class=\"topbar\"><div><strong>Komp Accounting</strong></div><nav><a href=\"/admin\">Admin</a><a href=\"/\">Analytics</a></nav></header><main class=\"form-main\"><a class=\"back-link\" href=\"/admin\">← Admin panel</a><section class=\"form-card\"><p class=\"eyebrow\">Table definition</p><h1>Add table</h1><p>Create a table through the existing gRPC table-definition service.</p><form hx-post=\"/admin/tables\" hx-target=\"#submission-status\" hx-swap=\"innerHTML\" hx-disabled-elt=\"button[type=submit]\"><div class=\"form-grid\"><label>Profile<select name=\"profile_name\" required><option value=\"\">Choose a profile</option>{options}</select></label><label>Table name<input name=\"table_name\" value=\"{}\" required placeholder=\"invoices\"></label><label class=\"wide\">Columns<textarea name=\"columns\" rows=\"9\" required placeholder=\"number: text:indexed issued_on: date amount: money:half-up\">{}</textarea><small>One per line: <code>name: type: optional flags</code>. Flags: indexed, half-up.</small></label><label>Additional indexed columns<input name=\"indexed_columns\" value=\"{}\" placeholder=\"number, issued_on\"></label><label>Base currency<input name=\"base_currency\" value=\"{}\" maxlength=\"3\" placeholder=\"EUR\"></label><label>Required links<input name=\"required_links\" value=\"{}\" placeholder=\"customer, address\"></label><label>Optional links<input name=\"optional_links\" value=\"{}\" placeholder=\"project\"></label><label>Row display columns<input name=\"row_display_columns\" value=\"{}\" placeholder=\"name, ico\"></label></div><div id=\"submission-status\" aria-live=\"polite\">{error}</div><div class=\"form-actions\"><a href=\"/admin\">Cancel</a><button type=\"submit\">Create table</button></div></form></section></main></body></html>",
|
||||
crate::escape_html(&page.form.table_name),
|
||||
crate::escape_html(&page.form.columns),
|
||||
crate::escape_html(&page.form.indexed_columns),
|
||||
|
||||
@@ -113,7 +113,6 @@ pub(crate) async fn load_admin_page(
|
||||
data_type: column.data_type.clone(),
|
||||
nullable: column.is_nullable,
|
||||
primary_key: column.is_primary_key,
|
||||
recompute_on_dependency_change: column.recompute_on_dependency_change,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ pub(crate) struct ColumnView {
|
||||
pub data_type: String,
|
||||
pub nullable: bool,
|
||||
pub primary_key: bool,
|
||||
pub recompute_on_dependency_change: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -95,9 +95,6 @@ fn render_columns(page: &AdminPageState) -> String {
|
||||
} else {
|
||||
flags.push("required");
|
||||
}
|
||||
if column.recompute_on_dependency_change {
|
||||
flags.push("recomputed");
|
||||
}
|
||||
format!(
|
||||
"<div class=\"column\"><span>{}</span><code>{}</code><small>{}</small></div>",
|
||||
crate::escape_html(&column.name),
|
||||
|
||||
2
server
2
server
Submodule server updated: df7f5aaf95...b44238ec3b
Reference in New Issue
Block a user