From e5b6074305c5ecbe625881b3b3e23bbff34a64eb Mon Sep 17 00:00:00 2001 From: Gudule Lapointe Date: Sun, 16 Mar 2025 22:14:27 +0100 Subject: [PATCH] * add directory_info.php script, prividing basic stats of search directory content --- directory_info.php | 91 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 directory_info.php diff --git a/directory_info.php b/directory_info.php new file mode 100644 index 0000000..520643f --- /dev/null +++ b/directory_info.php @@ -0,0 +1,91 @@ +prepareAndExecute( + 'SELECT * FROM parcels + INNER JOIN ' . SEARCH_REGION_TABLE . ' AS r ON parcels.regionUUID = r.regionUUID', +); +$registered_parcels = $query->fetchAll(PDO::FETCH_ASSOC); +$grids_info = osdb_cache_get( 'grids_info', array() ); + +// Calculate stats per gatekeeperURL +$stats = []; +foreach ($registered_parcels as $host) { + $gatekeeperURL = $host['gatekeeperURL']; + $grids_info[$gatekeeperURL] = $grids_info[$gatekeeperURL] ?? OpenSim_Grid::get_grid_info($gatekeeperURL); + if (!isset($stats[$gatekeeperURL])) { + $stats[$gatekeeperURL] = [ + 'regions' => [], + 'parcels' => 0, + ]; + } + $stats[$gatekeeperURL]['parcels']++; + $region = $host['regionUUID']; + $stats[$gatekeeperURL]['regions'][$region] = true; +} + +osdb_cache_set( 'grids_info', $grids_info, 86400 ); + +$grid_count = count($stats); +$allregionscount = 0; +$allparcelscount = 0; +foreach ($stats as $gatekeeperURL => $data) { + $regionCount = count($data['regions']); + $allregionscount += $regionCount; + $parcelCount = $data['parcels']; + $allparcelscount += $parcelCount; + $gridname = $grids_info[$gatekeeperURL]['gridname'] ?? $gatekeeperURL; + $stats_display .= sprintf( + '%s (%d regions, %d parcels)   ', + $gatekeeperURL, + $gridname, + $regionCount, + $parcelCount + ); + + // "$gatekeeperURL ($regionCount regions, $parcelCount parcels)   "; +} + +$content = sprintf( + '%d grids, %d regions, %d parcels ', + $grid_count, + $allregionscount, + $allparcelscount +); +$content .= $stats_display; +// $content .= "

Grid info cache:

" . print_r($grids_info, true) . "

"; + +if(! empty($debug)) { + $content .= '
 

Debug data:

' . print_r( $debug, true ) . '
'; +} + +$sidebar_right= "Right"; +$sidebar_left = "Left"; + +// $content = $page->get_content(); + +// Last step is to load template to display the page. +require( 'templates/templates.php' );