feat: Add calendar VFS implementation
- Adds a new virtual file system (VFS) implementation for calendar data. - The calendar VFS provides a read-only view of calendar events, organized by calendar, date, title, and organizer. - Includes new modules for factory, model, and implementation details. - Adds unit tests to verify the functionality of the calendar VFS.
This commit is contained in:
@@ -1,49 +1,46 @@
|
||||
module radixtree
|
||||
|
||||
import freeflowuniverse.herolib.data.ourdb
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
// Gets a node from the database by its ID
|
||||
pub fn (mut rt RadixTree) get_node_by_id(id u32) !Node {
|
||||
node_data := rt.db.get(id)!
|
||||
node := deserialize_node(node_data)!
|
||||
//console.print_debug('Debug: Retrieved node ${id} with ${node.children.len} children')
|
||||
// console.print_debug('Debug: Retrieved node ${id} with ${node.children.len} children')
|
||||
return node
|
||||
}
|
||||
|
||||
// Logs the current state of a node
|
||||
pub fn (mut rt RadixTree) debug_node(id u32, msg string) ! {
|
||||
node := rt.get_node_by_id(id)!
|
||||
//console.print_debug('Debug: ${msg}')
|
||||
//console.print_debug(' Node ID: ${id}')
|
||||
//console.print_debug(' Key Segment: "${node.key_segment}"')
|
||||
//console.print_debug(' Is Leaf: ${node.is_leaf}')
|
||||
//console.print_debug(' Children: ${node.children.len}')
|
||||
for child in node.children {
|
||||
//console.print_debug(' - Child ID: ${child.node_id}, Key Part: "${child.key_part}"')
|
||||
}
|
||||
// node := rt.get_node_by_id(id)!
|
||||
// // console.print_debug('Debug: ${msg}')
|
||||
// // console.print_debug(' Node ID: ${id}')
|
||||
// // console.print_debug(' Key Segment: "${node.key_segment}"')
|
||||
// // console.print_debug(' Is Leaf: ${node.is_leaf}')
|
||||
// // console.print_debug(' Children: ${node.children.len}')
|
||||
// for child in node.children {
|
||||
// // console.print_debug(' - Child ID: ${child.node_id}, Key Part: "${child.key_part}"')
|
||||
// }
|
||||
}
|
||||
|
||||
// Prints the current state of the database
|
||||
pub fn (mut rt RadixTree) debug_db() ! {
|
||||
//console.print_debug('\nDatabase State:')
|
||||
//console.print_debug('===============')
|
||||
// console.print_debug('\nDatabase State:')
|
||||
// console.print_debug('===============')
|
||||
mut next_id := rt.db.get_next_id()!
|
||||
for id := u32(0); id < next_id; id++ {
|
||||
if data := rt.db.get(id) {
|
||||
if node := deserialize_node(data) {
|
||||
//console.print_debug('ID ${id}:')
|
||||
//console.print_debug(' Key Segment: "${node.key_segment}"')
|
||||
//console.print_debug(' Is Leaf: ${node.is_leaf}')
|
||||
//console.print_debug(' Children: ${node.children.len}')
|
||||
// console.print_debug('ID ${id}:')
|
||||
// console.print_debug(' Key Segment: "${node.key_segment}"')
|
||||
// console.print_debug(' Is Leaf: ${node.is_leaf}')
|
||||
// console.print_debug(' Children: ${node.children.len}')
|
||||
for child in node.children {
|
||||
//console.print_debug(' - Child ID: ${child.node_id}, Key Part: "${child.key_part}"')
|
||||
// console.print_debug(' - Child ID: ${child.node_id}, Key Part: "${child.key_part}"')
|
||||
}
|
||||
} else {
|
||||
//console.print_debug('ID ${id}: Failed to deserialize node')
|
||||
// console.print_debug('ID ${id}: Failed to deserialize node')
|
||||
}
|
||||
} else {
|
||||
//console.print_debug('ID ${id}: No data')
|
||||
// console.print_debug('ID ${id}: No data')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,7 +66,7 @@ pub fn (mut rt RadixTree) print_tree_from_node(node_id u32, indent string) ! {
|
||||
}
|
||||
node_info += ']'
|
||||
}
|
||||
//console.print_debug(node_info)
|
||||
// console.print_debug(node_info)
|
||||
|
||||
// Print children recursively with increased indentation
|
||||
for i, child in node.children {
|
||||
@@ -85,8 +82,8 @@ pub fn (mut rt RadixTree) print_tree_from_node(node_id u32, indent string) ! {
|
||||
|
||||
// Prints the entire tree structure starting from root
|
||||
pub fn (mut rt RadixTree) print_tree() ! {
|
||||
//console.print_debug('\nRadix Tree Structure:')
|
||||
//console.print_debug('===================')
|
||||
// console.print_debug('\nRadix Tree Structure:')
|
||||
// console.print_debug('===================')
|
||||
rt.print_tree_from_node(rt.root_id, '')!
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user