/* ** Copyright (c) 2007 D. Richard Hipp ** ** This program is free software; you can redistribute it and/or ** modify it under the terms of the Simplified BSD License (also ** known as the "2-Clause License" or "FreeBSD License".) ** This program is distributed in the hope that it will be useful, ** but without any warranty; without even the implied warranty of ** merchantability or fitness for a particular purpose. ** ** Author contact information: ** drh@hwaci.com ** http://www.hwaci.com/drh/ ** ******************************************************************************* ** ** This file contains code to implement the stat web page ** */ #include #include "config.h" #include "stat.h" /* ** WEBPAGE: stat ** ** Show statistics and global information about the repository. */ void stat_page(void){ i64 t, fsize; int n, m; int szMax, szAvg; const char *zDb; int brief; char *z; char zBuf[200]; login_check_credentials(); if( !g.perm.Read ){ login_needed(); return; } brief = P("brief")!=0; style_header("Repository Statistics"); @ @ if( !brief ){ @ if( n>0 ){ int a, b; Stmt q; @ @ } @ @ @ @ } @ @ @ @ @ @ @
Repository Size: fsize = file_size(g.zRepositoryName); z = mprintf("%llD", fsize); @ %z(z) bytes @
Number Of Artifacts: n = db_int(0, "SELECT count(*) FROM blob"); m = db_int(0, "SELECT count(*) FROM delta"); @ %D(n) (stored as %D(n-m) full text and %D(m) delta blobs) @
Uncompressed Artifact Size: db_prepare(&q, "SELECT total(size), avg(size), max(size)" " FROM blob WHERE size>0"); db_step(&q); t = db_column_int64(&q, 0); szAvg = db_column_int(&q, 1); szMax = db_column_int(&q, 2); db_finalize(&q); z = mprintf("%llD", t); @ %D(szAvg) bytes average, %D(szMax) bytes max, %z(z) bytes total @
Compression Ratio: if( t/fsize < 5 ){ b = 10; fsize /= 10; }else{ b = 1; } a = t/fsize; @ %d(a):%d(b) @
Number Of Check-ins: n = db_int(0, "SELECT count(distinct mid) FROM mlink /*scan*/"); @ %D(n) @
Number Of Files: n = db_int(0, "SELECT count(*) FROM filename /*scan*/"); @ %D(n) @
Number Of Wiki Pages: n = db_int(0, "SELECT count(*) FROM tag /*scan*/" " WHERE +tagname GLOB 'wiki-*'"); @ %D(n) @
Number Of Tickets: n = db_int(0, "SELECT count(*) FROM tag /*scan*/" " WHERE +tagname GLOB 'tkt-*'"); @ %D(n) @
Duration Of Project: n = db_int(0, "SELECT julianday('now') - (SELECT min(mtime) FROM event)" " + 0.99"); @ %D(n) days sqlite3_snprintf(sizeof(zBuf), zBuf, "%.2f", n/365.24); @ or approximately %s(zBuf) years @
Project ID:%h(db_get("project-code",""))
Server ID:%h(db_get("server-code",""))
Fossil Version: @ %h(RELEASE_VERSION) %h(MANIFEST_DATE) %h(MANIFEST_VERSION) @ (%h(COMPILER_NAME)) @
SQLite Version: sqlite3_snprintf(sizeof(zBuf), zBuf, "%.19s [%.10s] (%s)", SQLITE_SOURCE_ID, &SQLITE_SOURCE_ID[20], SQLITE_VERSION); zDb = db_name("repository"); @ %s(zBuf) @
Database Stats: @ %d(db_int(0, "PRAGMA %s.page_count", zDb)) pages, @ %d(db_int(0, "PRAGMA %s.page_size", zDb)) bytes/page, @ %d(db_int(0, "PRAGMA %s.freelist_count", zDb)) free pages, @ %s(db_text(0, "PRAGMA %s.encoding", zDb)), @ %s(db_text(0, "PRAGMA %s.journal_mode", zDb)) mode @
style_footer(); }