Example #1
0
	OTHER DEALINGS IN THE SOFTWARE.
*/
require_once 'classes/piaApp.php';
$piaApp = new piaApp();
$piaApp->startPage('PiArchive Statistics');
$piaApp->addTableSorter();
$piaApp->showHeader('PiArchive Statistics');
$piaApp->addMenu('stats.php');
#
# ----- database version
#
$version = piaDB::getScalarString('SELECT * FROM pia_version()', array());
echo 'Database version: ', $version, '<p />';
#
# ----- total number of items
#
$num_sources = piaDB::getScalarInteger('SELECT count(rowid) FROM pia.source', array());
echo $num_sources, ' source(s)<p />';
$num_indexed_items = piaDB::getScalarInteger('SELECT count(rowid) FROM pia.index', array());
echo piaApp::getFormattedNumber($num_indexed_items, 0, -9), ' indexed item(s)<p />';
$size_bytes = piaDB::getScalarFloat('SELECT sum(size_bytes) FROM pia.index', array());
echo 'Total size of indexed items: ', piaApp::getFormattedNumber($size_bytes, 0, -9), ' (bytes)<p />';
#
# ----- show sources in a table
#
piaSource::reportSources();
#
# ----- footer and close page
#
$piaApp->showFooter();
$piaApp->closePage();
Example #2
0
    /**
     * Report indexed sources from pia.source.
     */
    public static function reportSources()
    {
        global $piaApp;
        //
        // ----- build SQL to read the data
        //
        $sql = 'SELECT ' . piaSource::getFields();
        $sql .= ', i.num_items, i.size_bytes';
        $sql .= piaSource::getJoins();
        $sql .= ' INNER JOIN
						(
						  SELECT i.source_rowid_fk, COUNT(i.rowid) AS num_items,
						    SUM(i.size_bytes) AS size_bytes
						  FROM pia.index i
						  GROUP BY i.source_rowid_fk
						) i ON i.source_rowid_fk = source.rowid';
        //
        // ----- connect to the database and read the data
        //
        $db = piaDB::connect();
        if ($db) {
            $result = pg_query($db, $sql);
            if (!$result) {
                piaDB::errorWithSQL($sql);
            }
            if (pg_num_rows($result) > 0) {
                $s = new piaSource();
                echo '<h2>Sources</h2>';
                $tableId = 'SourcesTable';
                $piaApp->initTablesorterTable($tableId);
                piaApp::startTable($tableId, 'tablesorter', False, 'width:70%;');
                piaApp::writeTableHeader(array(array('Name', '35%'), array('Description', '35%'), array('Num Items', '15%'), array('Size (bytes)', '15%')));
                echo '<tbody>';
                //
                // ----- loop through the results
                //
                while ($row = pg_fetch_array($result)) {
                    $cur = $s->readRowFromDatabase($row);
                    $num_items = piaDB::cleanDataRead($row[$cur++]);
                    $size_bytes = piaDB::cleanDataRead($row[$cur++]);
                    echo '<tr>';
                    piaApp::writeTableData($s->name);
                    piaApp::writeTableData($s->description);
                    piaApp::writeTableData(piaApp::getFormattedNumber($num_items, 0, -9));
                    piaApp::writeTableData(piaApp::getFormattedNumber($size_bytes, 0, -9));
                    echo '</tr>';
                }
                echo '</tbody></table><p />';
            }
            pg_free_result($result);
            piaDB::close($db);
        }
    }