content::revision::file_stats (private)

 content::revision::file_stats [ -max max ]

Defined in packages/acs-content-repository/tcl/content-revision-procs.tcl

Determine some basic statistics about files in the CR based on a sample. This is useful for large installations with several million of files, where a detailed analysis would take very long.

Switches:
-max (optional, defaults to "10000")
number of revisions with storage-type "file" to check
Author:
Gustaf Neumann

Partial Call Graph (max 5 caller/called nodes):
%3 content::revision::item_id content::revision::item_id (public) db_list_of_lists db_list_of_lists (public) content::revision::file_stats content::revision::file_stats content::revision::file_stats->content::revision::item_id content::revision::file_stats->db_list_of_lists

Testcases:
No testcase defined.
Source code:
    set tuples [db_list_of_lists get_file_names {
        select i.item_id, revision_id, mime_type, content_length
        from cr_items i, cr_revisions r
        where storage_type = 'file'
        and storage_area_key = 'CR_FILES'
        and  r.item_id = i.item_id
        FETCH FIRST :max ROWS ONLY
    }]
    set count 0
    set total_length 0
    set empty_files 0
    foreach tuple $tuples {
        lassign $tuple item_id revision_id mime_type content_length
        incr count
        if {$content_length eq ""} {
            ns_log warning "file_stats: entry has no content_length: revision_id $revision_id mime_type $mime_type"
        } else {
            incr total_length $content_length
        }
        incr mime_types($mime_type)
        incr revisions_for_item($item_id)
        if {$content_length < 1} {
            incr empty_files
        }
    }
    set result ""
    if {$count > 0} {
        set backup_files 0
        set files_with_multiple_revisions 0
        foreach {item_id revs} [array get revisions_for_item] {
            if {$revs > 1} {
                incr files_with_multiple_revisions
                incr backup_files [expr {$revs - 1}]
            }
        }
        set most_common [lrange [lsort  -integer  -stride 2  -index 1  -decreasing  [array get mime_types]
                                ] 0 11]

        append result  "checked files                : $count\n"  "files with multiple revisions: $files_with_multiple_revisions\n"  "backup files                 : $backup_files\n"  "empty files                  : $empty_files\n"  "avg file size                : [format %10.2f [expr {$total_length*1.0/$count}]]\n"  "mime_types: $most_common"
        ns_log notice "file_stats: $result"
    }
    return $result
Generic XQL file:
packages/acs-content-repository/tcl/content-revision-procs.xql

PostgreSQL XQL file:
packages/acs-content-repository/tcl/content-revision-procs-postgresql.xql

Oracle XQL file:
packages/acs-content-repository/tcl/content-revision-procs-oracle.xql

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