category_tree::reset_cache (public)

 category_tree::reset_cache

Defined in packages/categories/tcl/category-trees-procs.tcl

Reloads all category tree hierarchies in the cache.

Author:
Timo Hentschel <timo@timohentschel.de>

Partial Call Graph (max 5 caller/called nodes):
%3 test_category_crud category_crud (test categories) category_tree::reset_cache category_tree::reset_cache test_category_crud->category_tree::reset_cache db_foreach db_foreach (public) category_tree::reset_cache->db_foreach packages/categories/tcl/categories-init.tcl packages/categories/ tcl/categories-init.tcl packages/categories/tcl/categories-init.tcl->category_tree::reset_cache

Testcases:
category_crud
Source code:
        if {[nsv_names category_trees] ne ""} {
            nsv_unset category_trees
        }

        set tree_id_old 0
        set cur_level 1
        set stack [list]
        set invalid_p ""
        set tree [list]
        db_foreach reset_cache {
        select tree_id, category_id, left_ind, right_ind,
               case when deprecated_p = 'f' then '' else '1' end as deprecated_p
        from categories
        order by tree_id, left_ind
        } {
            if {$tree_id != $tree_id_old && $tree_id_old != 0} {
                nsv_set category_trees $tree_id_old $tree
                set cur_level 1
                set stack [list]
                set invalid_p ""
                set tree [list]
            }
            set tree_id_old $tree_id
            lappend tree [list $category_id [expr {"$invalid_p$deprecated_p" eq "" ? f : t}] $cur_level]
            if { $right_ind - $left_ind > 1} {
                incr cur_level 1
                set invalid_p "$invalid_p$deprecated_p"
                set stack [linsert $stack 0 [list $right_ind $invalid_p]]
            } else {
                incr right_ind 1
                while {$right_ind == [lindex $stack 0 0] && $cur_level > 0} {
                    incr cur_level -1
                    incr right_ind 1
                    set stack [lrange $stack 1 end]
                }
                set invalid_p [lindex $stack 0 1]
            }
        }
        if {$tree_id_old != 0} {
            nsv_set category_trees $tree_id $tree
        }
XQL Not present:
Generic
PostgreSQL XQL file:
packages/categories/tcl/category-trees-procs-postgresql.xql

Oracle XQL file:
packages/categories/tcl/category-trees-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: