Artifact bc484277064e5bcf7c2dc0a2eb0329e543aec966
File
src/stat.c
part of check-in
[caa9544f93]
- Tweaks to the formatting of the "stat" webpage.
by
drh on
2008-11-09 22:59:18.
/*
** Copyright (c) 2007 D. Richard Hipp
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public
** License version 2 as published by the Free Software Foundation.
**
** 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. See the GNU
** General Public License for more details.
**
** You should have received a copy of the GNU General Public
** License along with this library; if not, write to the
** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
** Boston, MA 02111-1307, USA.
**
** Author contact information:
** drh@hwaci.com
** http://www.hwaci.com/drh/
**
*******************************************************************************
**
** This file contains code to implement the stat web page
**
*/
#include <string.h>
#include "config.h"
#include "stat.h"
/*
** WEBPAGE: stat
**
** Show statistics and global information about the repository.
*/
void stat_page(void){
i64 t;
int n, m, fsize;
char zBuf[100];
login_check_credentials();
if( !g.okRead ){ login_needed(); return; }
style_header("Repository Statistics");
@ <p><table class="label-value">
@ <tr><th>Repository Size:</th><td>
fsize = file_size(g.zRepositoryName);
@ %d(fsize) bytes
@ </td></tr>
@ <tr><th>Number Of Artifacts:</th><td>
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)
@ </td></tr>
if( n>0 ){
int a, b;
@ <tr><th>Uncompressed Artifact Size:</th><td>
t = db_int64(0, "SELECT total(size) FROM blob WHERE size>0");
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", t);
@ %d((int)(((double)t)/(double)n)) bytes average, %s(zBuf) bytes total
@ </td></tr>
@ <tr><th>Compression Ratio:</th><td>
if( t/fsize < 5 ){
b = 10;
fsize /= 10;
}else{
b = 1;
}
a = t/fsize;
@ %d(a):%d(b)
@ </td></tr>
}
@ <tr><th>Number Of Check-ins:</th><td>
n = db_int(0, "SELECT count(distinct mid) FROM mlink");
@ %d(n)
@ </td></tr>
@ <tr><th>Number Of Files:</th><td>
n = db_int(0, "SELECT count(*) FROM filename");
@ %d(n)
@ </td></tr>
@ <tr><th>Number Of Wiki Pages:</th><td>
n = db_int(0, "SELECT count(*) FROM tag WHERE +tagname GLOB 'wiki-*'");
@ %d(n)
@ </td></tr>
@ <tr><th>Number Of Tickets:</th><td>
n = db_int(0, "SELECT count(*) FROM tag WHERE +tagname GLOB 'tkt-*'");
@ %d(n)
@ </td></tr>
@ <tr><th>Duration Of Project:</th><td>
n = db_int(0, "SELECT julianday('now') - (SELECT min(mtime) FROM event) + 0.99");
@ %d(n) days
@ </td></tr>
@ <tr><th>Project ID:</th><td>
@ %h(db_get("project-code",""))
@ </td></tr>
@ <tr><th>Server ID:</th><td>
@ %h(db_get("server-code",""))
@ </td></tr>
@ </table></p>
style_footer();
}