18c2e8227SGreg Roach<?php 23976b470SGreg Roach 38c2e8227SGreg Roach/** 48c2e8227SGreg Roach * webtrees: online genealogy 5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 68c2e8227SGreg Roach * This program is free software: you can redistribute it and/or modify 78c2e8227SGreg Roach * it under the terms of the GNU General Public License as published by 88c2e8227SGreg Roach * the Free Software Foundation, either version 3 of the License, or 98c2e8227SGreg Roach * (at your option) any later version. 108c2e8227SGreg Roach * This program is distributed in the hope that it will be useful, 118c2e8227SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 128c2e8227SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 138c2e8227SGreg Roach * GNU General Public License for more details. 148c2e8227SGreg Roach * You should have received a copy of the GNU General Public License 1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 168c2e8227SGreg Roach */ 17fcfa147eSGreg Roach 18e7f56f2aSGreg Roachdeclare(strict_types=1); 19e7f56f2aSGreg Roach 2076692c8bSGreg Roachnamespace Fisharebest\Webtrees\Module; 2176692c8bSGreg Roach 220e62c4b8SGreg Roachuse Fisharebest\Webtrees\Auth; 236f4ec3caSGreg Roachuse Fisharebest\Webtrees\DB; 240e62c4b8SGreg Roachuse Fisharebest\Webtrees\I18N; 258fb4e87cSGreg Roachuse Fisharebest\Webtrees\Individual; 26d35568b4SGreg Roachuse Fisharebest\Webtrees\Registry; 2767992b6aSRichard Cisseeuse Fisharebest\Webtrees\Services\ModuleService; 289219296aSGreg Roachuse Fisharebest\Webtrees\Statistics; 29e490cd80SGreg Roachuse Fisharebest\Webtrees\Tree; 30748dbe15SGreg Roachuse Fisharebest\Webtrees\Validator; 31a69f5655SGreg Roachuse Illuminate\Database\Query\Expression; 321e7a7a28SGreg Roachuse Illuminate\Support\Str; 336ccdf4f0SGreg Roachuse Psr\Http\Message\ServerRequestInterface; 348c2e8227SGreg Roach 35b86c018aSGreg Roachuse function array_slice; 36cd1ec0d0SGreg Roachuse function extract; 37cd1ec0d0SGreg Roachuse function view; 38cd1ec0d0SGreg Roach 39cd1ec0d0SGreg Roachuse const EXTR_OVERWRITE; 40cd1ec0d0SGreg Roach 418c2e8227SGreg Roach/** 428c2e8227SGreg Roach * Class FamilyTreeStatisticsModule 438c2e8227SGreg Roach */ 4437eb8894SGreg Roachclass FamilyTreeStatisticsModule extends AbstractModule implements ModuleBlockInterface 45c1010edaSGreg Roach{ 4649a243cbSGreg Roach use ModuleBlockTrait; 4749a243cbSGreg Roach 48f36626dbSGreg Roach /** Show this number of surnames by default */ 49*e873f434SGreg Roach private const string DEFAULT_NUMBER_OF_SURNAMES = '10'; 50f36626dbSGreg Roach 51b55cbc6bSGreg Roach private ModuleService $module_service; 52b55cbc6bSGreg Roach 53b55cbc6bSGreg Roach /** 54b55cbc6bSGreg Roach * @param ModuleService $module_service 55b55cbc6bSGreg Roach */ 56b55cbc6bSGreg Roach public function __construct(ModuleService $module_service) 57b55cbc6bSGreg Roach { 58b55cbc6bSGreg Roach $this->module_service = $module_service; 59b55cbc6bSGreg Roach } 60b55cbc6bSGreg Roach 61961ec755SGreg Roach /** 620cfd6963SGreg Roach * How should this module be identified in the control panel, etc.? 63961ec755SGreg Roach * 64961ec755SGreg Roach * @return string 65961ec755SGreg Roach */ 6649a243cbSGreg Roach public function title(): string 67c1010edaSGreg Roach { 68bbb76c12SGreg Roach /* I18N: Name of a module */ 69bbb76c12SGreg Roach return I18N::translate('Statistics'); 708c2e8227SGreg Roach } 718c2e8227SGreg Roach 7249a243cbSGreg Roach public function description(): string 73c1010edaSGreg Roach { 74bbb76c12SGreg Roach /* I18N: Description of “Statistics” module */ 75bbb76c12SGreg Roach return I18N::translate('The size of the family tree, earliest and latest events, common names, etc.'); 768c2e8227SGreg Roach } 778c2e8227SGreg Roach 7876692c8bSGreg Roach /** 7976692c8bSGreg Roach * Generate the HTML content of this block. 8076692c8bSGreg Roach * 81e490cd80SGreg Roach * @param Tree $tree 8276692c8bSGreg Roach * @param int $block_id 833caaa4d2SGreg Roach * @param string $context 8476d39c55SGreg Roach * @param array<string,string> $config 8576692c8bSGreg Roach * 8676692c8bSGreg Roach * @return string 8776692c8bSGreg Roach */ 883caaa4d2SGreg Roach public function getBlock(Tree $tree, int $block_id, string $context, array $config = []): string 89c1010edaSGreg Roach { 90d35568b4SGreg Roach $statistics = Registry::container()->get(Statistics::class); 91bf57b580SGreg Roach 92e2a378d3SGreg Roach $show_last_update = $this->getBlockSetting($block_id, 'show_last_update', '1'); 93e2a378d3SGreg Roach $show_common_surnames = $this->getBlockSetting($block_id, 'show_common_surnames', '1'); 9480536c2dSGreg Roach $number_of_surnames = (int) $this->getBlockSetting($block_id, 'number_of_surnames', self::DEFAULT_NUMBER_OF_SURNAMES); 95e2a378d3SGreg Roach $stat_indi = $this->getBlockSetting($block_id, 'stat_indi', '1'); 96e2a378d3SGreg Roach $stat_fam = $this->getBlockSetting($block_id, 'stat_fam', '1'); 97e2a378d3SGreg Roach $stat_sour = $this->getBlockSetting($block_id, 'stat_sour', '1'); 98e2a378d3SGreg Roach $stat_media = $this->getBlockSetting($block_id, 'stat_media', '1'); 99e2a378d3SGreg Roach $stat_repo = $this->getBlockSetting($block_id, 'stat_repo', '1'); 100e2a378d3SGreg Roach $stat_surname = $this->getBlockSetting($block_id, 'stat_surname', '1'); 101e2a378d3SGreg Roach $stat_events = $this->getBlockSetting($block_id, 'stat_events', '1'); 102e2a378d3SGreg Roach $stat_users = $this->getBlockSetting($block_id, 'stat_users', '1'); 103e2a378d3SGreg Roach $stat_first_birth = $this->getBlockSetting($block_id, 'stat_first_birth', '1'); 104e2a378d3SGreg Roach $stat_last_birth = $this->getBlockSetting($block_id, 'stat_last_birth', '1'); 105e2a378d3SGreg Roach $stat_first_death = $this->getBlockSetting($block_id, 'stat_first_death', '1'); 106e2a378d3SGreg Roach $stat_last_death = $this->getBlockSetting($block_id, 'stat_last_death', '1'); 107e2a378d3SGreg Roach $stat_long_life = $this->getBlockSetting($block_id, 'stat_long_life', '1'); 108e2a378d3SGreg Roach $stat_avg_life = $this->getBlockSetting($block_id, 'stat_avg_life', '1'); 109e2a378d3SGreg Roach $stat_most_chil = $this->getBlockSetting($block_id, 'stat_most_chil', '1'); 110e2a378d3SGreg Roach $stat_avg_chil = $this->getBlockSetting($block_id, 'stat_avg_chil', '1'); 1118c2e8227SGreg Roach 1123caaa4d2SGreg Roach extract($config, EXTR_OVERWRITE); 1138c2e8227SGreg Roach 114b6ec1ccfSGreg Roach if ($show_common_surnames === '1') { 115b86c018aSGreg Roach $query = DB::table('name') 1161ae92905SGreg Roach ->where('n_file', '=', $tree->id()) 1171ae92905SGreg Roach ->where('n_type', '<>', '_MARNM') 118b86c018aSGreg Roach ->where('n_surn', '<>', '') 119b86c018aSGreg Roach ->where('n_surn', '<>', Individual::NOMEN_NESCIO) 120b86c018aSGreg Roach ->select([ 12152550490SGreg Roach DB::binaryColumn('n_surn', 'n_surn'), 12252550490SGreg Roach DB::binaryColumn('n_surname', 'n_surname'), 123b86c018aSGreg Roach new Expression('COUNT(*) AS total'), 124b86c018aSGreg Roach ]) 125b86c018aSGreg Roach ->groupBy([ 12652550490SGreg Roach DB::binaryColumn('n_surn'), 12752550490SGreg Roach DB::binaryColumn('n_surname'), 128b86c018aSGreg Roach ]); 129e0275e5bSGreg Roach 130b86c018aSGreg Roach /** @var array<array<int>> $top_surnames */ 131b86c018aSGreg Roach $top_surnames = []; 1321ae92905SGreg Roach 133b86c018aSGreg Roach foreach ($query->get() as $row) { 134b86c018aSGreg Roach $row->n_surn = $row->n_surn === '' ? $row->n_surname : $row->n_surn; 135b86c018aSGreg Roach $row->n_surn = I18N::strtoupper(I18N::language()->normalize($row->n_surn)); 13680536c2dSGreg Roach 137b86c018aSGreg Roach $top_surnames[$row->n_surn][$row->n_surname] ??= 0; 138b86c018aSGreg Roach $top_surnames[$row->n_surn][$row->n_surname] += (int) $row->total; 139f36626dbSGreg Roach } 14080536c2dSGreg Roach 141b86c018aSGreg Roach uasort($top_surnames, static fn (array $x, array $y): int => array_sum($y) <=> array_sum($x)); 142b86c018aSGreg Roach 143b86c018aSGreg Roach $top_surnames = array_slice($top_surnames, 0, $number_of_surnames, true); 1441d3c0c1aSGreg Roach 145b55cbc6bSGreg Roach // Find a module providing individual lists 146b55cbc6bSGreg Roach $module = $this->module_service 147b55cbc6bSGreg Roach ->findByComponent(ModuleListInterface::class, $tree, Auth::user()) 148b55cbc6bSGreg Roach ->first(static fn (ModuleInterface $module): bool => $module instanceof IndividualListModule); 14967992b6aSRichard Cissee 150cd1ec0d0SGreg Roach $surnames = view('lists/surnames-compact-list', [ 151cd1ec0d0SGreg Roach 'module' => $module, 152cd1ec0d0SGreg Roach 'totals' => false, 153b86c018aSGreg Roach 'surnames' => $top_surnames, 154cd1ec0d0SGreg Roach 'tree' => $tree, 155cd1ec0d0SGreg Roach ]); 1561d3c0c1aSGreg Roach } else { 1571d3c0c1aSGreg Roach $surnames = ''; 1588c2e8227SGreg Roach } 1591d3c0c1aSGreg Roach 160147e99aaSGreg Roach $content = view('modules/gedcom_stats/statistics', [ 1611d3c0c1aSGreg Roach 'show_last_update' => $show_last_update, 1621d3c0c1aSGreg Roach 'show_common_surnames' => $show_common_surnames, 1631d3c0c1aSGreg Roach 'number_of_surnames' => $number_of_surnames, 1641d3c0c1aSGreg Roach 'stat_indi' => $stat_indi, 1651d3c0c1aSGreg Roach 'stat_fam' => $stat_fam, 1661d3c0c1aSGreg Roach 'stat_sour' => $stat_sour, 1671d3c0c1aSGreg Roach 'stat_media' => $stat_media, 1681d3c0c1aSGreg Roach 'stat_repo' => $stat_repo, 1691d3c0c1aSGreg Roach 'stat_surname' => $stat_surname, 1701d3c0c1aSGreg Roach 'stat_events' => $stat_events, 1711d3c0c1aSGreg Roach 'stat_users' => $stat_users, 1721d3c0c1aSGreg Roach 'stat_first_birth' => $stat_first_birth, 1731d3c0c1aSGreg Roach 'stat_last_birth' => $stat_last_birth, 1741d3c0c1aSGreg Roach 'stat_first_death' => $stat_first_death, 1751d3c0c1aSGreg Roach 'stat_last_death' => $stat_last_death, 1761d3c0c1aSGreg Roach 'stat_long_life' => $stat_long_life, 1771d3c0c1aSGreg Roach 'stat_avg_life' => $stat_avg_life, 1781d3c0c1aSGreg Roach 'stat_most_chil' => $stat_most_chil, 1791d3c0c1aSGreg Roach 'stat_avg_chil' => $stat_avg_chil, 1801d3c0c1aSGreg Roach 'surnames' => $surnames, 1811d3c0c1aSGreg Roach ]); 18228941e3cSGreg Roach 183bd055353SGreg Roach $content = $statistics->embedTags($content); 184bd055353SGreg Roach 1853caaa4d2SGreg Roach if ($context !== self::CONTEXT_EMBED) { 186147e99aaSGreg Roach return view('modules/block-template', [ 1871e7a7a28SGreg Roach 'block' => Str::kebab($this->name()), 1889c6524dcSGreg Roach 'id' => $block_id, 1893caaa4d2SGreg Roach 'config_url' => $this->configUrl($tree, $context, $block_id), 19049a243cbSGreg Roach 'title' => $this->title(), 1919c6524dcSGreg Roach 'content' => $content, 1929c6524dcSGreg Roach ]); 1938c2e8227SGreg Roach } 194b2ce94c6SRico Sonntag 195b2ce94c6SRico Sonntag return $content; 1968c2e8227SGreg Roach } 1978c2e8227SGreg Roach 1983caaa4d2SGreg Roach /** 1993caaa4d2SGreg Roach * Should this block load asynchronously using AJAX? 2003caaa4d2SGreg Roach * 2013caaa4d2SGreg Roach * Simple blocks are faster in-line, more complex ones can be loaded later. 2023caaa4d2SGreg Roach * 2033caaa4d2SGreg Roach * @return bool 2043caaa4d2SGreg Roach */ 205c1010edaSGreg Roach public function loadAjax(): bool 206c1010edaSGreg Roach { 2078c2e8227SGreg Roach return true; 2088c2e8227SGreg Roach } 2098c2e8227SGreg Roach 2103caaa4d2SGreg Roach /** 2113caaa4d2SGreg Roach * Can this block be shown on the user’s home page? 2123caaa4d2SGreg Roach * 2133caaa4d2SGreg Roach * @return bool 2143caaa4d2SGreg Roach */ 215c1010edaSGreg Roach public function isUserBlock(): bool 216c1010edaSGreg Roach { 2178c2e8227SGreg Roach return true; 2188c2e8227SGreg Roach } 2198c2e8227SGreg Roach 2203caaa4d2SGreg Roach /** 2213caaa4d2SGreg Roach * Can this block be shown on the tree’s home page? 2223caaa4d2SGreg Roach * 2233caaa4d2SGreg Roach * @return bool 2243caaa4d2SGreg Roach */ 22563276d8fSGreg Roach public function isTreeBlock(): bool 226c1010edaSGreg Roach { 2278c2e8227SGreg Roach return true; 2288c2e8227SGreg Roach } 2298c2e8227SGreg Roach 23076692c8bSGreg Roach /** 231a45f9889SGreg Roach * Update the configuration for a block. 232a45f9889SGreg Roach * 2336ccdf4f0SGreg Roach * @param ServerRequestInterface $request 234a45f9889SGreg Roach * @param int $block_id 235a45f9889SGreg Roach * 236a45f9889SGreg Roach * @return void 237a45f9889SGreg Roach */ 2386ccdf4f0SGreg Roach public function saveBlockConfiguration(ServerRequestInterface $request, int $block_id): void 239a45f9889SGreg Roach { 240748dbe15SGreg Roach $show_last_update = Validator::parsedBody($request)->boolean('show_last_update', false); 241748dbe15SGreg Roach $show_common_surnames = Validator::parsedBody($request)->boolean('show_common_surnames', false); 242748dbe15SGreg Roach $number_of_surnames = Validator::parsedBody($request)->integer('number_of_surnames'); 243748dbe15SGreg Roach $stat_indi = Validator::parsedBody($request)->boolean('stat_indi', false); 244748dbe15SGreg Roach $stat_fam = Validator::parsedBody($request)->boolean('stat_fam', false); 245748dbe15SGreg Roach $stat_sour = Validator::parsedBody($request)->boolean('stat_sour', false); 246748dbe15SGreg Roach $stat_other = Validator::parsedBody($request)->boolean('stat_other', false); 247748dbe15SGreg Roach $stat_media = Validator::parsedBody($request)->boolean('stat_media', false); 248748dbe15SGreg Roach $stat_repo = Validator::parsedBody($request)->boolean('stat_repo', false); 249748dbe15SGreg Roach $stat_surname = Validator::parsedBody($request)->boolean('stat_surname', false); 250748dbe15SGreg Roach $stat_events = Validator::parsedBody($request)->boolean('stat_events', false); 251748dbe15SGreg Roach $stat_users = Validator::parsedBody($request)->boolean('stat_users', false); 252748dbe15SGreg Roach $stat_first_birth = Validator::parsedBody($request)->boolean('stat_first_birth', false); 253748dbe15SGreg Roach $stat_last_birth = Validator::parsedBody($request)->boolean('stat_last_birth', false); 254748dbe15SGreg Roach $stat_first_death = Validator::parsedBody($request)->boolean('stat_first_death', false); 255748dbe15SGreg Roach $stat_last_death = Validator::parsedBody($request)->boolean('stat_last_death', false); 256748dbe15SGreg Roach $stat_long_life = Validator::parsedBody($request)->boolean('stat_long_life', false); 257748dbe15SGreg Roach $stat_avg_life = Validator::parsedBody($request)->boolean('stat_avg_life', false); 258748dbe15SGreg Roach $stat_most_chil = Validator::parsedBody($request)->boolean('stat_most_chil', false); 259748dbe15SGreg Roach $stat_avg_chil = Validator::parsedBody($request)->boolean('stat_avg_chil', false); 260ac5f8ed1SGreg Roach 261748dbe15SGreg Roach $this->setBlockSetting($block_id, 'show_last_update', (string) $show_last_update); 262748dbe15SGreg Roach $this->setBlockSetting($block_id, 'show_common_surnames', (string) $show_common_surnames); 263748dbe15SGreg Roach $this->setBlockSetting($block_id, 'number_of_surnames', (string) $number_of_surnames); 264748dbe15SGreg Roach $this->setBlockSetting($block_id, 'stat_indi', (string) $stat_indi); 265748dbe15SGreg Roach $this->setBlockSetting($block_id, 'stat_fam', (string) $stat_fam); 266748dbe15SGreg Roach $this->setBlockSetting($block_id, 'stat_sour', (string) $stat_sour); 267748dbe15SGreg Roach $this->setBlockSetting($block_id, 'stat_other', (string) $stat_other); 268748dbe15SGreg Roach $this->setBlockSetting($block_id, 'stat_media', (string) $stat_media); 269748dbe15SGreg Roach $this->setBlockSetting($block_id, 'stat_repo', (string) $stat_repo); 270748dbe15SGreg Roach $this->setBlockSetting($block_id, 'stat_surname', (string) $stat_surname); 271748dbe15SGreg Roach $this->setBlockSetting($block_id, 'stat_events', (string) $stat_events); 272748dbe15SGreg Roach $this->setBlockSetting($block_id, 'stat_users', (string) $stat_users); 273748dbe15SGreg Roach $this->setBlockSetting($block_id, 'stat_first_birth', (string) $stat_first_birth); 274748dbe15SGreg Roach $this->setBlockSetting($block_id, 'stat_last_birth', (string) $stat_last_birth); 275748dbe15SGreg Roach $this->setBlockSetting($block_id, 'stat_first_death', (string) $stat_first_death); 276748dbe15SGreg Roach $this->setBlockSetting($block_id, 'stat_last_death', (string) $stat_last_death); 277748dbe15SGreg Roach $this->setBlockSetting($block_id, 'stat_long_life', (string) $stat_long_life); 278748dbe15SGreg Roach $this->setBlockSetting($block_id, 'stat_avg_life', (string) $stat_avg_life); 279748dbe15SGreg Roach $this->setBlockSetting($block_id, 'stat_most_chil', (string) $stat_most_chil); 280748dbe15SGreg Roach $this->setBlockSetting($block_id, 'stat_avg_chil', (string) $stat_avg_chil); 281a45f9889SGreg Roach } 282a45f9889SGreg Roach 283a45f9889SGreg Roach /** 28476692c8bSGreg Roach * An HTML form to edit block settings 28576692c8bSGreg Roach * 286e490cd80SGreg Roach * @param Tree $tree 28776692c8bSGreg Roach * @param int $block_id 288a9430be8SGreg Roach * 2893caaa4d2SGreg Roach * @return string 29076692c8bSGreg Roach */ 2913caaa4d2SGreg Roach public function editBlockConfiguration(Tree $tree, int $block_id): string 292c1010edaSGreg Roach { 293e2a378d3SGreg Roach $show_last_update = $this->getBlockSetting($block_id, 'show_last_update', '1'); 294e2a378d3SGreg Roach $show_common_surnames = $this->getBlockSetting($block_id, 'show_common_surnames', '1'); 295f36626dbSGreg Roach $number_of_surnames = $this->getBlockSetting($block_id, 'number_of_surnames', self::DEFAULT_NUMBER_OF_SURNAMES); 296e2a378d3SGreg Roach $stat_indi = $this->getBlockSetting($block_id, 'stat_indi', '1'); 297e2a378d3SGreg Roach $stat_fam = $this->getBlockSetting($block_id, 'stat_fam', '1'); 298e2a378d3SGreg Roach $stat_sour = $this->getBlockSetting($block_id, 'stat_sour', '1'); 299e2a378d3SGreg Roach $stat_media = $this->getBlockSetting($block_id, 'stat_media', '1'); 300e2a378d3SGreg Roach $stat_repo = $this->getBlockSetting($block_id, 'stat_repo', '1'); 301e2a378d3SGreg Roach $stat_surname = $this->getBlockSetting($block_id, 'stat_surname', '1'); 302e2a378d3SGreg Roach $stat_events = $this->getBlockSetting($block_id, 'stat_events', '1'); 303e2a378d3SGreg Roach $stat_users = $this->getBlockSetting($block_id, 'stat_users', '1'); 304e2a378d3SGreg Roach $stat_first_birth = $this->getBlockSetting($block_id, 'stat_first_birth', '1'); 305e2a378d3SGreg Roach $stat_last_birth = $this->getBlockSetting($block_id, 'stat_last_birth', '1'); 306e2a378d3SGreg Roach $stat_first_death = $this->getBlockSetting($block_id, 'stat_first_death', '1'); 307e2a378d3SGreg Roach $stat_last_death = $this->getBlockSetting($block_id, 'stat_last_death', '1'); 308e2a378d3SGreg Roach $stat_long_life = $this->getBlockSetting($block_id, 'stat_long_life', '1'); 309e2a378d3SGreg Roach $stat_avg_life = $this->getBlockSetting($block_id, 'stat_avg_life', '1'); 310e2a378d3SGreg Roach $stat_most_chil = $this->getBlockSetting($block_id, 'stat_most_chil', '1'); 311e2a378d3SGreg Roach $stat_avg_chil = $this->getBlockSetting($block_id, 'stat_avg_chil', '1'); 3128c2e8227SGreg Roach 3133caaa4d2SGreg Roach return view('modules/gedcom_stats/config', [ 314c385536dSGreg Roach 'show_last_update' => $show_last_update, 315c385536dSGreg Roach 'show_common_surnames' => $show_common_surnames, 316c385536dSGreg Roach 'number_of_surnames' => $number_of_surnames, 317c385536dSGreg Roach 'stat_indi' => $stat_indi, 318c385536dSGreg Roach 'stat_fam' => $stat_fam, 319c385536dSGreg Roach 'stat_sour' => $stat_sour, 320c385536dSGreg Roach 'stat_media' => $stat_media, 321c385536dSGreg Roach 'stat_repo' => $stat_repo, 322c385536dSGreg Roach 'stat_surname' => $stat_surname, 323c385536dSGreg Roach 'stat_events' => $stat_events, 324c385536dSGreg Roach 'stat_users' => $stat_users, 325c385536dSGreg Roach 'stat_first_birth' => $stat_first_birth, 326c385536dSGreg Roach 'stat_last_birth' => $stat_last_birth, 327c385536dSGreg Roach 'stat_first_death' => $stat_first_death, 328c385536dSGreg Roach 'stat_last_death' => $stat_last_death, 329c385536dSGreg Roach 'stat_long_life' => $stat_long_life, 330c385536dSGreg Roach 'stat_avg_life' => $stat_avg_life, 331c385536dSGreg Roach 'stat_most_chil' => $stat_most_chil, 332c385536dSGreg Roach 'stat_avg_chil' => $stat_avg_chil, 333c385536dSGreg Roach ]); 3348c2e8227SGreg Roach } 3358c2e8227SGreg Roach} 336