Made regular tables request session info.
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s

This commit is contained in:
2026-03-21 11:44:49 -04:00
parent 8a8006c521
commit 046d71e606
3 changed files with 66 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
use super::{InternalRecord, InternalRecords, Oid}; use super::Session;
use super::{DocFeature, InternalRecord, InternalRecords, Oid};
use crate::{ use crate::{
action::{Action, CalcValue, Calculation, MsgAction, Query, Records, Reply, Update}, action::{Action, CalcValue, Calculation, MsgAction, Query, Records, Reply, Update},
document::{ document::{
@@ -452,8 +453,12 @@ impl DocumentFile {
} }
fn listen(&mut self) { fn listen(&mut self) {
let sess_name = Session::doc_names()[0].clone();
loop { loop {
let msg = self.rx.recv().unwrap(); let msg = self.rx.recv().unwrap();
if !self.docdef.has_feature(&DocFeature::System) {
self.queue.send(Message::new(Query::new(sess_name.clone())));
}
let route = msg.get_route(); let route = msg.get_route();
for (route_id, doc_func) in self.routes.clone().iter() { for (route_id, doc_func) in self.routes.clone().iter() {
if route == route_id.into() { if route == route_id.into() {
@@ -782,3 +787,55 @@ impl DocumentFile {
.send(msg.forward(self.name_id.clone(), action.clone())); .send(msg.forward(self.name_id.clone(), action.clone()));
} }
} }
#[cfg(test)]
mod internal_features {
use super::*;
use crate::{Name, TestMoreThanText};
use std::sync::mpsc::RecvTimeoutError;
#[test]
fn do_system_documents_ignores_session() {
let sess_name = Session::doc_names()[0].clone();
let mut test_env = TestMoreThanText::new();
let mut mtt = test_env.get_morethantext();
let name = Name::english("something");
let docdef = DocDef::system(name.clone());
mtt.create_document(docdef);
let path = Path::new(
Include::All,
Include::Just(sess_name.clone().into()),
Include::Just(Action::Query),
);
test_env.register_channel(vec![path]);
mtt.records(Query::new(name)).unwrap();
match test_env.recv() {
Ok(msg) => unreachable!("got {:?} should have timed out", msg),
Err(err) => match err {
RecvTimeoutError::Timeout => {}
_ => unreachable!("got {:?}, should have timed out", err),
},
}
}
#[test]
fn do_normal_definitions_request_session() {
let sess_name = Session::doc_names()[0].clone();
let mut test_env = TestMoreThanText::new();
let mut mtt = test_env.get_morethantext();
let name = Name::english("something");
let docdef = DocDef::new(name.clone());
mtt.create_document(docdef);
let path = Path::new(
Include::All,
Include::Just(sess_name.clone().into()),
Include::Just(Action::Query),
);
test_env.register_channel(vec![path]);
mtt.records(Query::new(name)).unwrap();
match test_env.recv() {
Ok(msg) => {}
Err(err) => unreachable!("got {:?}, should have requested session", err),
}
}
}

View File

@@ -313,6 +313,13 @@ impl DocDef {
&mut self.field_names &mut self.field_names
} }
pub fn has_feature(&self, feature: &DocFeature) -> bool {
match self.features.get(feature) {
Some(_) => true,
None => false,
}
}
pub fn add_field(&mut self, names: Vec<Name>, ftype: FieldType) { pub fn add_field(&mut self, names: Vec<Name>, ftype: FieldType) {
let id = self.field_names.add_names(names).unwrap(); let id = self.field_names.add_names(names).unwrap();
self.fields.insert(id, FieldSetting::new(ftype)); self.fields.insert(id, FieldSetting::new(ftype));

View File

@@ -50,7 +50,7 @@ impl Session {
let name_expire = Self::expire_field_names()[0].clone(); let name_expire = Self::expire_field_names()[0].clone();
let name_lang = Self::language_field_names()[0].clone(); let name_lang = Self::language_field_names()[0].clone();
let mut docdef = DocDef::with_names(Self::doc_names()); let mut docdef = DocDef::system_with_names(Self::doc_names());
let mut calc = Calculation::new(Operand::Add); let mut calc = Calculation::new(Operand::Add);
calc.add_value(FieldType::DateTime).unwrap(); calc.add_value(FieldType::DateTime).unwrap();