Some checks failed
BotServer CI / build (push) Failing after 1m34s
Split 20+ files over 1000 lines into focused subdirectories for better maintainability and code organization. All changes maintain backward compatibility through re-export wrappers. Major splits: - attendance/llm_assist.rs (2074→7 modules) - basic/keywords/face_api.rs → face_api/ (7 modules) - basic/keywords/file_operations.rs → file_ops/ (8 modules) - basic/keywords/hear_talk.rs → hearing/ (6 modules) - channels/wechat.rs → wechat/ (10 modules) - channels/youtube.rs → youtube/ (5 modules) - contacts/mod.rs → contacts_api/ (6 modules) - core/bootstrap/mod.rs → bootstrap/ (5 modules) - core/shared/admin.rs → admin_*.rs (5 modules) - designer/canvas.rs → canvas_api/ (6 modules) - designer/mod.rs → designer_api/ (6 modules) - docs/handlers.rs → handlers_api/ (11 modules) - drive/mod.rs → drive_handlers.rs, drive_types.rs - learn/mod.rs → types.rs - main.rs → main_module/ (7 modules) - meet/webinar.rs → webinar_api/ (8 modules) - paper/mod.rs → (10 modules) - security/auth.rs → auth_api/ (7 modules) - security/passkey.rs → (4 modules) - sources/mod.rs → sources_api/ (5 modules) - tasks/mod.rs → task_api/ (5 modules) Stats: 38,040 deletions, 1,315 additions across 318 files Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
140 lines
3.2 KiB
Rust
140 lines
3.2 KiB
Rust
use crate::core::shared::models::UserSession;
|
|
use crate::core::shared::state::AppState;
|
|
use log::debug;
|
|
use rhai::{Dynamic, Engine};
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
pub fn nvl_keyword(_state: &Arc<AppState>, _user: UserSession, engine: &mut Engine) {
|
|
|
|
engine.register_fn("NVL", |value: Dynamic, default: Dynamic| -> Dynamic {
|
|
if value.is_unit() || value.to_string().is_empty() {
|
|
default
|
|
} else {
|
|
value
|
|
}
|
|
});
|
|
|
|
engine.register_fn("nvl", |value: Dynamic, default: Dynamic| -> Dynamic {
|
|
if value.is_unit() || value.to_string().is_empty() {
|
|
default
|
|
} else {
|
|
value
|
|
}
|
|
});
|
|
|
|
|
|
engine.register_fn("COALESCE", |value: Dynamic, default: Dynamic| -> Dynamic {
|
|
if value.is_unit() || value.to_string().is_empty() {
|
|
default
|
|
} else {
|
|
value
|
|
}
|
|
});
|
|
|
|
engine.register_fn("coalesce", |value: Dynamic, default: Dynamic| -> Dynamic {
|
|
if value.is_unit() || value.to_string().is_empty() {
|
|
default
|
|
} else {
|
|
value
|
|
}
|
|
});
|
|
|
|
|
|
engine.register_fn("IFNULL", |value: Dynamic, default: Dynamic| -> Dynamic {
|
|
if value.is_unit() || value.to_string().is_empty() {
|
|
default
|
|
} else {
|
|
value
|
|
}
|
|
});
|
|
|
|
engine.register_fn("ifnull", |value: Dynamic, default: Dynamic| -> Dynamic {
|
|
if value.is_unit() || value.to_string().is_empty() {
|
|
default
|
|
} else {
|
|
value
|
|
}
|
|
});
|
|
|
|
debug!("Registered NVL/COALESCE/IFNULL keywords");
|
|
}
|
|
|
|
|
|
|
|
pub fn iif_keyword(_state: &Arc<AppState>, _user: UserSession, engine: &mut Engine) {
|
|
|
|
engine.register_fn(
|
|
"IIF",
|
|
|condition: bool, true_val: Dynamic, false_val: Dynamic| -> Dynamic {
|
|
if condition {
|
|
true_val
|
|
} else {
|
|
false_val
|
|
}
|
|
},
|
|
);
|
|
|
|
engine.register_fn(
|
|
"iif",
|
|
|condition: bool, true_val: Dynamic, false_val: Dynamic| -> Dynamic {
|
|
if condition {
|
|
true_val
|
|
} else {
|
|
false_val
|
|
}
|
|
},
|
|
);
|
|
|
|
|
|
engine.register_fn(
|
|
"IF_FUNC",
|
|
|condition: bool, true_val: Dynamic, false_val: Dynamic| -> Dynamic {
|
|
if condition {
|
|
true_val
|
|
} else {
|
|
false_val
|
|
}
|
|
},
|
|
);
|
|
|
|
|
|
engine.register_fn(
|
|
"CHOOSE",
|
|
|index: i64, val1: Dynamic, val2: Dynamic| -> Dynamic {
|
|
match index {
|
|
1 => val1,
|
|
2 => val2,
|
|
_ => Dynamic::UNIT,
|
|
}
|
|
},
|
|
);
|
|
|
|
engine.register_fn(
|
|
"choose",
|
|
|index: i64, val1: Dynamic, val2: Dynamic| -> Dynamic {
|
|
match index {
|
|
1 => val1,
|
|
2 => val2,
|
|
_ => Dynamic::UNIT,
|
|
}
|
|
},
|
|
);
|
|
|
|
|
|
|
|
|
|
engine.register_fn(
|
|
"SWITCH_FUNC",
|
|
|expr: Dynamic, val1: Dynamic, result1: Dynamic, default: Dynamic| -> Dynamic {
|
|
if expr.to_string() == val1.to_string() {
|
|
result1
|
|
} else {
|
|
default
|
|
}
|
|
},
|
|
);
|
|
|
|
debug!("Registered IIF/IF_FUNC/CHOOSE/SWITCH_FUNC keywords");
|
|
}
|