@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function icon(ModuleInterface $module): string |
| 39 | 39 | { |
| 40 | - return view($module->name() . '::icons/view-table', ['type' => $this->type()]); |
|
| 40 | + return view($module->name().'::icons/view-table', ['type' => $this->type()]); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | public function globalTabContent(GeoDispersionModule $module, GeoAnalysisResult $result, array $params): string |
| 67 | 67 | { |
| 68 | - return view($module->name() . '::geoanalysisview-tab-glb-table', $params + [ |
|
| 68 | + return view($module->name().'::geoanalysisview-tab-glb-table', $params + [ |
|
| 69 | 69 | 'result' => $result |
| 70 | 70 | ]); |
| 71 | 71 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function icon(ModuleInterface $module): string |
| 46 | 46 | { |
| 47 | - return view($module->name() . '::icons/view-map', ['type' => $this->type()]); |
|
| 47 | + return view($module->name().'::icons/view-map', ['type' => $this->type()]); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function globalSettingsContent(ModuleInterface $module): string |
| 55 | 55 | { |
| 56 | - return view($module->name() . '::admin/view-edit-map', [ |
|
| 56 | + return view($module->name().'::admin/view-edit-map', [ |
|
| 57 | 57 | 'module_name' => $module->name(), |
| 58 | 58 | 'view' => $this, |
| 59 | 59 | 'colors' => $this->colors(), |
@@ -68,12 +68,12 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function withGlobalSettingsUpdate(ServerRequestInterface $request): self |
| 70 | 70 | { |
| 71 | - $params = (array) $request->getParsedBody(); |
|
| 71 | + $params = (array)$request->getParsedBody(); |
|
| 72 | 72 | |
| 73 | 73 | $default_color = $params['view_map_color_default'] ?? ''; |
| 74 | 74 | $stroke_color = $params['view_map_color_stroke'] ?? ''; |
| 75 | - $maxvalue_color = $params['view_map_color_maxvalue'] ?? ''; |
|
| 76 | - $hover_color = $params['view_map_color_hover'] ?? ''; |
|
| 75 | + $maxvalue_color = $params['view_map_color_maxvalue'] ?? ''; |
|
| 76 | + $hover_color = $params['view_map_color_hover'] ?? ''; |
|
| 77 | 77 | |
| 78 | 78 | try { |
| 79 | 79 | return $this->withColors(new MapColorsConfig( |
@@ -100,17 +100,16 @@ discard block |
||
| 100 | 100 | foreach ($map_adapters as $map_adapter) { |
| 101 | 101 | $adapter_result_tmp = $map_adapter->convert($result); |
| 102 | 102 | $adapter_result = $adapter_result === null ? |
| 103 | - $adapter_result_tmp : |
|
| 104 | - $adapter_result->merge($adapter_result_tmp); |
|
| 103 | + $adapter_result_tmp : $adapter_result->merge($adapter_result_tmp); |
|
| 105 | 104 | } |
| 106 | 105 | |
| 107 | 106 | if ($adapter_result === null) { |
| 108 | - return view($module->name() . '::errors/tab-error', [ |
|
| 107 | + return view($module->name().'::errors/tab-error', [ |
|
| 109 | 108 | 'message' => I18N::translate('The map could not be loaded.'), |
| 110 | 109 | ]); |
| 111 | 110 | } |
| 112 | 111 | |
| 113 | - return view($module->name() . '::geoanalysisview-tab-glb-map', $params + [ |
|
| 112 | + return view($module->name().'::geoanalysisview-tab-glb-map', $params + [ |
|
| 114 | 113 | 'result' => $adapter_result->geoAnalysisResult(), |
| 115 | 114 | 'features' => $adapter_result->features(), |
| 116 | 115 | 'colors' => $this->colors(), |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | // How to update the database schema for this module |
| 74 | 74 | private const SCHEMA_TARGET_VERSION = 3; |
| 75 | 75 | private const SCHEMA_SETTING_NAME = 'MAJ_SOSA_SCHEMA_VERSION'; |
| 76 | - private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
| 76 | + private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__.'\Schema'; |
|
| 77 | 77 | /** |
| 78 | 78 | * {@inheritDoc} |
| 79 | 79 | * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
@@ -113,25 +113,25 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function loadRoutes(Map $router): void |
| 115 | 115 | { |
| 116 | - $router->attach('', '', static function (Map $router): void { |
|
| 116 | + $router->attach('', '', static function(Map $router): void { |
|
| 117 | 117 | |
| 118 | - $router->attach('', '/module-maj/sosa', static function (Map $router): void { |
|
| 118 | + $router->attach('', '/module-maj/sosa', static function(Map $router): void { |
|
| 119 | 119 | |
| 120 | - $router->attach('', '/list', static function (Map $router): void { |
|
| 120 | + $router->attach('', '/list', static function(Map $router): void { |
|
| 121 | 121 | $router->tokens(['gen' => '\d+']); |
| 122 | 122 | $router->get(AncestorsList::class, '/ancestors/{tree}{/gen}', AncestorsList::class); |
| 123 | - $router->get(AncestorsListIndividual::class, '/ancestors/{tree}/{gen}/tab/individuals', AncestorsListIndividual::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 124 | - $router->get(AncestorsListFamily::class, '/ancestors/{tree}/{gen}/tab/families', AncestorsListFamily::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 123 | + $router->get(AncestorsListIndividual::class, '/ancestors/{tree}/{gen}/tab/individuals', AncestorsListIndividual::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 124 | + $router->get(AncestorsListFamily::class, '/ancestors/{tree}/{gen}/tab/families', AncestorsListFamily::class); //phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 125 | 125 | $router->get(MissingAncestorsList::class, '/missing/{tree}{/gen}', MissingAncestorsList::class); |
| 126 | 126 | }); |
| 127 | 127 | |
| 128 | - $router->attach('', '/statistics/{tree}', static function (Map $router): void { |
|
| 128 | + $router->attach('', '/statistics/{tree}', static function(Map $router): void { |
|
| 129 | 129 | |
| 130 | 130 | $router->get(SosaStatistics::class, '', SosaStatistics::class); |
| 131 | 131 | $router->get(PedigreeCollapseData::class, '/pedigreecollapse', PedigreeCollapseData::class); |
| 132 | 132 | }); |
| 133 | 133 | |
| 134 | - $router->attach('', '/config/{tree}', static function (Map $router): void { |
|
| 134 | + $router->attach('', '/config/{tree}', static function(Map $router): void { |
|
| 135 | 135 | |
| 136 | 136 | $router->get(SosaConfig::class, '', SosaConfig::class); |
| 137 | 137 | $router->post(SosaConfigAction::class, '', SosaConfigAction::class); |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | public function headContent(): string |
| 232 | 232 | { |
| 233 | - return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
| 233 | + return '<link rel="stylesheet" href="'.e($this->moduleCssUrl()).'">'; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | */ |
| 240 | 240 | public function bodyContent(): string |
| 241 | 241 | { |
| 242 | - return '<script src="' . $this->assetUrl('js/sosa.min.js') . '"></script>'; |
|
| 242 | + return '<script src="'.$this->assetUrl('js/sosa.min.js').'"></script>'; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | { |
| 251 | 251 | $user = Auth::check() ? Auth::user() : new DefaultUser(); |
| 252 | 252 | |
| 253 | - return view($this->name() . '::sidebar/title', [ |
|
| 253 | + return view($this->name().'::sidebar/title', [ |
|
| 254 | 254 | 'module_name' => $this->name(), |
| 255 | 255 | 'sosa_numbers' => app(SosaRecordsService::class)->sosaNumbers($individual->tree(), $user, $individual) |
| 256 | 256 | ]); |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | $sosa_root = Registry::individualFactory()->make($sosa_root_xref, $individual->tree()); |
| 267 | 267 | $user = Auth::check() ? Auth::user() : new DefaultUser(); |
| 268 | 268 | |
| 269 | - return view($this->name() . '::sidebar/content', [ |
|
| 269 | + return view($this->name().'::sidebar/content', [ |
|
| 270 | 270 | 'sosa_ancestor' => $individual, |
| 271 | 271 | 'sosa_root' => $sosa_root, |
| 272 | 272 | 'sosa_numbers' => app(SosaRecordsService::class)->sosaNumbers($individual->tree(), $user, $individual) |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | public function listSubscribedHooks(): array |
| 313 | 313 | { |
| 314 | 314 | return [ |
| 315 | - app()->makeWith(SosaIconHook::class, [ 'module' => $this ]) |
|
| 315 | + app()->makeWith(SosaIconHook::class, ['module' => $this]) |
|
| 316 | 316 | ]; |
| 317 | 317 | } |
| 318 | 318 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function maxGeneration(): int |
| 64 | 64 | { |
| 65 | - return (int) DB::table('maj_sosa') |
|
| 65 | + return (int)DB::table('maj_sosa') |
|
| 66 | 66 | ->where('majs_gedcom_id', '=', $this->tree->id()) |
| 67 | 67 | ->where('majs_user_id', '=', $this->user->id()) |
| 68 | 68 | ->max('majs_gen'); |
@@ -139,8 +139,7 @@ discard block |
||
| 139 | 139 | ->selectRaw('SUM(majs_gen * majs_gen) AS sum_x2') |
| 140 | 140 | ->get()->first(); |
| 141 | 141 | |
| 142 | - return $row->n == 0 ? 0 : |
|
| 143 | - -($row->n * $row->sum_xy - $row->sum_x * $row->sum_y) / ($row->n * $row->sum_x2 - pow($row->sum_x, 2)); |
|
| 142 | + return $row->n == 0 ? 0 : -($row->n * $row->sum_xy - $row->sum_x * $row->sum_y) / ($row->n * $row->sum_x2 - pow($row->sum_x, 2)); |
|
| 144 | 143 | } |
| 145 | 144 | |
| 146 | 145 | /** |
@@ -164,10 +163,10 @@ discard block |
||
| 164 | 163 | |
| 165 | 164 | $statistics_by_gen = []; |
| 166 | 165 | foreach ($stats_by_gen as $gen => $stats_gen) { |
| 167 | - $statistics_by_gen[(int) $stats_gen->gen] = array( |
|
| 168 | - 'sosaCount' => (int) $stats_gen->total_sosa, |
|
| 169 | - 'sosaTotalCount' => (int) $cumul_stats_by_gen[$gen]->total_cumul, |
|
| 170 | - 'diffSosaTotalCount' => (int) $cumul_stats_by_gen[$gen]->total_distinct_cumul, |
|
| 166 | + $statistics_by_gen[(int)$stats_gen->gen] = array( |
|
| 167 | + 'sosaCount' => (int)$stats_gen->total_sosa, |
|
| 168 | + 'sosaTotalCount' => (int)$cumul_stats_by_gen[$gen]->total_cumul, |
|
| 169 | + 'diffSosaTotalCount' => (int)$cumul_stats_by_gen[$gen]->total_distinct_cumul, |
|
| 171 | 170 | 'firstBirth' => $stats_gen->first_year, |
| 172 | 171 | 'firstEstimatedBirth' => $stats_gen->first_est_year, |
| 173 | 172 | 'lastBirth' => $stats_gen->last_year, |
@@ -211,7 +210,7 @@ discard block |
||
| 211 | 210 | ->where('majs_user_id', '=', $this->user->id()); |
| 212 | 211 | |
| 213 | 212 | return DB::table('maj_sosa') |
| 214 | - ->joinSub($list_gen, 'list_gen', function (JoinClause $join): void { |
|
| 213 | + ->joinSub($list_gen, 'list_gen', function(JoinClause $join): void { |
|
| 215 | 214 | $join->on('maj_sosa.majs_gen', '<=', 'list_gen.majs_gen') |
| 216 | 215 | ->where('majs_gedcom_id', '=', $this->tree->id()) |
| 217 | 216 | ->where('majs_user_id', '=', $this->user->id()); |
@@ -248,37 +247,37 @@ discard block |
||
| 248 | 247 | ->select(['list_gen.majs_gen AS gen', 'sosa.majs_gedcom_id', 'sosa.majs_user_id']) |
| 249 | 248 | ->addSelect(['sosa.majs_i_id', 'sosa.majs_gen']) |
| 250 | 249 | ->selectRaw( |
| 251 | - '(CASE ' . |
|
| 252 | - ' WHEN ' . $table_prefix . 'sosa_fat.majs_i_id IS NULL' . |
|
| 253 | - ' THEN POWER(2, ' . $table_prefix . 'list_gen.majs_gen - ' . $table_prefix . 'sosa.majs_gen - 1)' . |
|
| 254 | - ' ELSE 0 ' . |
|
| 255 | - ' END)' . |
|
| 256 | - ' + (CASE ' . |
|
| 257 | - ' WHEN ' . $table_prefix . 'sosa_mot.majs_i_id IS NULL' . |
|
| 258 | - ' THEN POWER(2, ' . $table_prefix . 'list_gen.majs_gen - ' . $table_prefix . 'sosa.majs_gen - 1)' . |
|
| 259 | - ' ELSE 0 ' . |
|
| 250 | + '(CASE '. |
|
| 251 | + ' WHEN '.$table_prefix.'sosa_fat.majs_i_id IS NULL'. |
|
| 252 | + ' THEN POWER(2, '.$table_prefix.'list_gen.majs_gen - '.$table_prefix.'sosa.majs_gen - 1)'. |
|
| 253 | + ' ELSE 0 '. |
|
| 254 | + ' END)'. |
|
| 255 | + ' + (CASE '. |
|
| 256 | + ' WHEN '.$table_prefix.'sosa_mot.majs_i_id IS NULL'. |
|
| 257 | + ' THEN POWER(2, '.$table_prefix.'list_gen.majs_gen - '.$table_prefix.'sosa.majs_gen - 1)'. |
|
| 258 | + ' ELSE 0 '. |
|
| 260 | 259 | ' END) contrib' |
| 261 | 260 | ) |
| 262 | - ->joinSub($list_gen, 'list_gen', function (JoinClause $join): void { |
|
| 261 | + ->joinSub($list_gen, 'list_gen', function(JoinClause $join): void { |
|
| 263 | 262 | $join->on('sosa.majs_gen', '<', 'list_gen.majs_gen') |
| 264 | 263 | ->where('majs_gedcom_id', '=', $this->tree->id()) |
| 265 | 264 | ->where('majs_user_id', '=', $this->user->id()); |
| 266 | 265 | }) |
| 267 | - ->leftJoin('maj_sosa AS sosa_fat', function (JoinClause $join) use ($table_prefix): void { |
|
| 266 | + ->leftJoin('maj_sosa AS sosa_fat', function(JoinClause $join) use ($table_prefix): void { |
|
| 268 | 267 | // Link to sosa's father |
| 269 | - $join->whereRaw($table_prefix . 'sosa_fat.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa') |
|
| 268 | + $join->whereRaw($table_prefix.'sosa_fat.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa') |
|
| 270 | 269 | ->where('sosa_fat.majs_gedcom_id', '=', $this->tree->id()) |
| 271 | 270 | ->where('sosa_fat.majs_user_id', '=', $this->user->id()); |
| 272 | 271 | }) |
| 273 | - ->leftJoin('maj_sosa AS sosa_mot', function (JoinClause $join) use ($table_prefix): void { |
|
| 272 | + ->leftJoin('maj_sosa AS sosa_mot', function(JoinClause $join) use ($table_prefix): void { |
|
| 274 | 273 | // Link to sosa's mother |
| 275 | - $join->whereRaw($table_prefix . 'sosa_mot.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa + 1') |
|
| 274 | + $join->whereRaw($table_prefix.'sosa_mot.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa + 1') |
|
| 276 | 275 | ->where('sosa_mot.majs_gedcom_id', '=', $this->tree->id()) |
| 277 | 276 | ->where('sosa_mot.majs_user_id', '=', $this->user->id()); |
| 278 | 277 | }) |
| 279 | 278 | ->where('sosa.majs_gedcom_id', '=', $this->tree->id()) |
| 280 | 279 | ->where('sosa.majs_user_id', '=', $this->user->id()) |
| 281 | - ->where(function (Builder $query): void { |
|
| 280 | + ->where(function(Builder $query): void { |
|
| 282 | 281 | $query->whereNull('sosa_fat.majs_i_id') |
| 283 | 282 | ->orWhereNull('sosa_mot.majs_i_id'); |
| 284 | 283 | }); |
@@ -288,24 +287,24 @@ discard block |
||
| 288 | 287 | */ |
| 289 | 288 | $non_roots_ancestors = DB::table('maj_sosa AS sosa') |
| 290 | 289 | ->select(['sosa.majs_gen', 'sosa.majs_gedcom_id', 'sosa.majs_user_id', 'sosa.majs_sosa']) |
| 291 | - ->selectRaw('MAX(' . $table_prefix . 'sosa_anc.majs_sosa) - MIN(' . $table_prefix . 'sosa_anc.majs_sosa)' . |
|
| 290 | + ->selectRaw('MAX('.$table_prefix.'sosa_anc.majs_sosa) - MIN('.$table_prefix.'sosa_anc.majs_sosa)'. |
|
| 292 | 291 | ' AS full_ancestors') |
| 293 | - ->join('maj_sosa AS sosa_anc', function (JoinClause $join) use ($table_prefix): void { |
|
| 292 | + ->join('maj_sosa AS sosa_anc', function(JoinClause $join) use ($table_prefix): void { |
|
| 294 | 293 | $join->on('sosa.majs_gen', '<', 'sosa_anc.majs_gen') |
| 295 | - ->whereRaw('FLOOR(' . $table_prefix . 'sosa_anc.majs_sosa / POWER(2, ' . |
|
| 296 | - $table_prefix . 'sosa_anc.majs_gen - ' . $table_prefix . 'sosa.majs_gen)) = ' . |
|
| 297 | - $table_prefix . 'sosa.majs_sosa') |
|
| 294 | + ->whereRaw('FLOOR('.$table_prefix.'sosa_anc.majs_sosa / POWER(2, '. |
|
| 295 | + $table_prefix.'sosa_anc.majs_gen - '.$table_prefix.'sosa.majs_gen)) = '. |
|
| 296 | + $table_prefix.'sosa.majs_sosa') |
|
| 298 | 297 | ->where('sosa_anc.majs_gedcom_id', '=', $this->tree->id()) |
| 299 | 298 | ->where('sosa_anc.majs_user_id', '=', $this->user->id()); |
| 300 | 299 | }) |
| 301 | 300 | ->where('sosa.majs_gedcom_id', '=', $this->tree->id()) |
| 302 | 301 | ->where('sosa.majs_user_id', '=', $this->user->id()) |
| 303 | - ->whereIn('sosa_anc.majs_i_id', function (Builder $query) use ($table_prefix): void { |
|
| 302 | + ->whereIn('sosa_anc.majs_i_id', function(Builder $query) use ($table_prefix): void { |
|
| 304 | 303 | $query->from('maj_sosa AS sosa_gen') |
| 305 | 304 | ->select('sosa_gen.majs_i_id')->distinct() |
| 306 | 305 | ->where('sosa_gen.majs_gedcom_id', '=', $this->tree->id()) |
| 307 | 306 | ->where('sosa_gen.majs_user_id', '=', $this->user->id()) |
| 308 | - ->whereRaw($table_prefix . 'sosa_gen.majs_gen = ' . $table_prefix . 'sosa.majs_gen'); |
|
| 307 | + ->whereRaw($table_prefix.'sosa_gen.majs_gen = '.$table_prefix.'sosa.majs_gen'); |
|
| 309 | 308 | }) |
| 310 | 309 | ->groupBy(['sosa.majs_gen', 'sosa.majs_gedcom_id', 'sosa.majs_user_id', |
| 311 | 310 | 'sosa.majs_sosa', 'sosa.majs_i_id']); |
@@ -318,7 +317,7 @@ discard block |
||
| 318 | 317 | ->select(['sosa.majs_gen AS gen', 'sosa.majs_gedcom_id', 'sosa.majs_user_id']) |
| 319 | 318 | ->addSelect(['sosa.majs_i_id', 'sosa.majs_gen']) |
| 320 | 319 | ->selectRaw('1 AS contrib') |
| 321 | - ->leftJoinSub($non_roots_ancestors, 'nonroot', function (JoinClause $join): void { |
|
| 320 | + ->leftJoinSub($non_roots_ancestors, 'nonroot', function(JoinClause $join): void { |
|
| 322 | 321 | $join->on('sosa.majs_gen', '=', 'nonroot.majs_gen') |
| 323 | 322 | ->on('sosa.majs_sosa', '=', 'nonroot.majs_sosa') |
| 324 | 323 | ->where('nonroot.full_ancestors', '>', 0) |
@@ -336,9 +335,9 @@ discard block |
||
| 336 | 335 | ->fromSub($root_ancestors_contributions->unionAll($known_ancestors_contributions), 'sosa_contribs') |
| 337 | 336 | ->select(['sosa_contribs.gen', 'sosa_contribs.majs_gedcom_id', 'sosa_contribs.majs_user_id']) |
| 338 | 337 | ->addSelect(['sosa_contribs.majs_i_id', 'sosa_contribs.contrib']) |
| 339 | - ->selectRaw('COUNT(' . $table_prefix . 'sosa_contribs.majs_i_id) * ' . |
|
| 340 | - $table_prefix . 'sosa_contribs.contrib AS totalContrib') |
|
| 341 | - ->leftJoin('maj_sosa AS sosa_low', function (JoinClause $join): void { |
|
| 338 | + ->selectRaw('COUNT('.$table_prefix.'sosa_contribs.majs_i_id) * '. |
|
| 339 | + $table_prefix.'sosa_contribs.contrib AS totalContrib') |
|
| 340 | + ->leftJoin('maj_sosa AS sosa_low', function(JoinClause $join): void { |
|
| 342 | 341 | $join->on('sosa_low.majs_gen', '<', 'sosa_contribs.majs_gen') |
| 343 | 342 | ->on('sosa_low.majs_i_id', '=', 'sosa_contribs.majs_i_id') |
| 344 | 343 | ->where('sosa_low.majs_gedcom_id', '=', $this->tree->id()) |
@@ -359,9 +358,9 @@ discard block |
||
| 359 | 358 | |
| 360 | 359 | $pedi_collapse_by_gen = []; |
| 361 | 360 | foreach ($pedi_collapse_coll as $collapse_gen) { |
| 362 | - $pedi_collapse_by_gen[(int) $collapse_gen->gen] = array( |
|
| 363 | - 'pedi_collapse_roots' => (float) $collapse_gen->pedi_collapse_roots, |
|
| 364 | - 'pedi_collapse_xgen' => (float) $collapse_gen->pedi_collapse_xgen |
|
| 361 | + $pedi_collapse_by_gen[(int)$collapse_gen->gen] = array( |
|
| 362 | + 'pedi_collapse_roots' => (float)$collapse_gen->pedi_collapse_roots, |
|
| 363 | + 'pedi_collapse_xgen' => (float)$collapse_gen->pedi_collapse_xgen |
|
| 365 | 364 | ); |
| 366 | 365 | } |
| 367 | 366 | return $pedi_collapse_by_gen; |
@@ -389,26 +388,26 @@ discard block |
||
| 389 | 388 | { |
| 390 | 389 | $table_prefix = DB::connection()->getTablePrefix(); |
| 391 | 390 | $missing_ancestors_by_gen = DB::table('maj_sosa AS sosa') |
| 392 | - ->selectRaw($table_prefix . 'sosa.majs_gen - ? AS majs_gen_norm', [$gen]) |
|
| 393 | - ->selectRaw('FLOOR(((' . $table_prefix . 'sosa.majs_sosa / POW(2, ' . $table_prefix . 'sosa.majs_gen -1 )) - 1) * POWER(2, ? - 1)) + POWER(2, ? - 1) AS root_ancestor', [$gen, $gen]) //@phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 394 | - ->selectRaw('SUM(CASE WHEN ' . $table_prefix . 'sosa_fat.majs_i_id IS NULL AND ' . $table_prefix . 'sosa_mot.majs_i_id IS NULL THEN 1 ELSE 0 END) AS full_root_count') //@phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 395 | - ->selectRaw('SUM(CASE WHEN ' . $table_prefix . 'sosa_fat.majs_i_id IS NULL AND ' . $table_prefix . 'sosa_mot.majs_i_id IS NULL THEN 0 ELSE 1 END) As semi_root_count') //@phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 396 | - ->leftJoin('maj_sosa AS sosa_fat', function (JoinClause $join) use ($table_prefix): void { |
|
| 391 | + ->selectRaw($table_prefix.'sosa.majs_gen - ? AS majs_gen_norm', [$gen]) |
|
| 392 | + ->selectRaw('FLOOR((('.$table_prefix.'sosa.majs_sosa / POW(2, '.$table_prefix.'sosa.majs_gen -1 )) - 1) * POWER(2, ? - 1)) + POWER(2, ? - 1) AS root_ancestor', [$gen, $gen]) //@phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 393 | + ->selectRaw('SUM(CASE WHEN '.$table_prefix.'sosa_fat.majs_i_id IS NULL AND '.$table_prefix.'sosa_mot.majs_i_id IS NULL THEN 1 ELSE 0 END) AS full_root_count') //@phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 394 | + ->selectRaw('SUM(CASE WHEN '.$table_prefix.'sosa_fat.majs_i_id IS NULL AND '.$table_prefix.'sosa_mot.majs_i_id IS NULL THEN 0 ELSE 1 END) As semi_root_count') //@phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 395 | + ->leftJoin('maj_sosa AS sosa_fat', function(JoinClause $join) use ($table_prefix): void { |
|
| 397 | 396 | // Link to sosa's father |
| 398 | - $join->whereRaw($table_prefix . 'sosa_fat.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa') |
|
| 397 | + $join->whereRaw($table_prefix.'sosa_fat.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa') |
|
| 399 | 398 | ->where('sosa_fat.majs_gedcom_id', '=', $this->tree->id()) |
| 400 | 399 | ->where('sosa_fat.majs_user_id', '=', $this->user->id()); |
| 401 | 400 | }) |
| 402 | - ->leftJoin('maj_sosa AS sosa_mot', function (JoinClause $join) use ($table_prefix): void { |
|
| 401 | + ->leftJoin('maj_sosa AS sosa_mot', function(JoinClause $join) use ($table_prefix): void { |
|
| 403 | 402 | // Link to sosa's mother |
| 404 | - $join->whereRaw($table_prefix . 'sosa_mot.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa + 1') |
|
| 403 | + $join->whereRaw($table_prefix.'sosa_mot.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa + 1') |
|
| 405 | 404 | ->where('sosa_mot.majs_gedcom_id', '=', $this->tree->id()) |
| 406 | 405 | ->where('sosa_mot.majs_user_id', '=', $this->user->id()); |
| 407 | 406 | }) |
| 408 | 407 | ->where('sosa.majs_gedcom_id', '=', $this->tree->id()) |
| 409 | 408 | ->where('sosa.majs_user_id', '=', $this->user->id()) |
| 410 | 409 | ->where('sosa.majs_gen', '>=', $gen) |
| 411 | - ->where(function (Builder $query): void { |
|
| 410 | + ->where(function(Builder $query): void { |
|
| 412 | 411 | $query->whereNull('sosa_fat.majs_i_id') |
| 413 | 412 | ->orWhereNull('sosa_mot.majs_i_id'); |
| 414 | 413 | }) |
@@ -417,11 +416,11 @@ discard block |
||
| 417 | 416 | return DB::table('maj_sosa AS sosa_list') |
| 418 | 417 | ->select(['stats_by_gen.root_ancestor AS root_ancestor_sosa', 'sosa_list.majs_i_id as root_ancestor_id']) |
| 419 | 418 | ->selectRaw('1 + SUM( (majs_gen_norm) * ( 2 * full_root_count + semi_root_count) / (2 * POWER(2, majs_gen_norm))) AS mean_gen_depth') //@phpcs:ignore Generic.Files.LineLength.TooLong |
| 420 | - ->selectRaw(' SQRT(' . |
|
| 421 | - ' SUM(POWER(majs_gen_norm, 2) * ( 2 * full_root_count + semi_root_count) / (2 * POWER(2, majs_gen_norm)))' . //@phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 422 | - ' - POWER( SUM( (majs_gen_norm) * ( 2 * full_root_count + semi_root_count) / (2 * POWER(2, majs_gen_norm))), 2)' . //@phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 419 | + ->selectRaw(' SQRT('. |
|
| 420 | + ' SUM(POWER(majs_gen_norm, 2) * ( 2 * full_root_count + semi_root_count) / (2 * POWER(2, majs_gen_norm)))'.//@phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 421 | + ' - POWER( SUM( (majs_gen_norm) * ( 2 * full_root_count + semi_root_count) / (2 * POWER(2, majs_gen_norm))), 2)'.//@phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 423 | 422 | ' ) AS stddev_gen_depth') |
| 424 | - ->joinSub($missing_ancestors_by_gen, 'stats_by_gen', function (JoinClause $join): void { |
|
| 423 | + ->joinSub($missing_ancestors_by_gen, 'stats_by_gen', function(JoinClause $join): void { |
|
| 425 | 424 | $join->on('sosa_list.majs_sosa', '=', 'stats_by_gen.root_ancestor') |
| 426 | 425 | ->where('sosa_list.majs_gedcom_id', '=', $this->tree->id()) |
| 427 | 426 | ->where('sosa_list.majs_user_id', '=', $this->user->id()); |
@@ -450,16 +449,16 @@ discard block |
||
| 450 | 449 | $table_prefix = DB::connection()->getTablePrefix(); |
| 451 | 450 | $multiple_ancestors = DB::table('maj_sosa AS sosa') |
| 452 | 451 | ->select('sosa.majs_i_id AS sosa_i_id') |
| 453 | - ->selectRaw('COUNT(' . $table_prefix . 'sosa.majs_sosa) AS sosa_count') |
|
| 454 | - ->leftJoin('maj_sosa AS sosa_fat', function (JoinClause $join) use ($table_prefix): void { |
|
| 452 | + ->selectRaw('COUNT('.$table_prefix.'sosa.majs_sosa) AS sosa_count') |
|
| 453 | + ->leftJoin('maj_sosa AS sosa_fat', function(JoinClause $join) use ($table_prefix): void { |
|
| 455 | 454 | // Link to sosa's father |
| 456 | - $join->whereRaw($table_prefix . 'sosa_fat.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa') |
|
| 455 | + $join->whereRaw($table_prefix.'sosa_fat.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa') |
|
| 457 | 456 | ->where('sosa_fat.majs_gedcom_id', '=', $this->tree->id()) |
| 458 | 457 | ->where('sosa_fat.majs_user_id', '=', $this->user->id()); |
| 459 | 458 | }) |
| 460 | - ->leftJoin('maj_sosa AS sosa_mot', function (JoinClause $join) use ($table_prefix): void { |
|
| 459 | + ->leftJoin('maj_sosa AS sosa_mot', function(JoinClause $join) use ($table_prefix): void { |
|
| 461 | 460 | // Link to sosa's mother |
| 462 | - $join->whereRaw($table_prefix . 'sosa_mot.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa + 1') |
|
| 461 | + $join->whereRaw($table_prefix.'sosa_mot.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa + 1') |
|
| 463 | 462 | ->where('sosa_mot.majs_gedcom_id', '=', $this->tree->id()) |
| 464 | 463 | ->where('sosa_mot.majs_user_id', '=', $this->user->id()); |
| 465 | 464 | }) |
@@ -468,15 +467,15 @@ discard block |
||
| 468 | 467 | ->whereNull('sosa_fat.majs_sosa') // We keep only root individuals, i.e. those with no father or mother |
| 469 | 468 | ->whereNull('sosa_mot.majs_sosa') |
| 470 | 469 | ->groupBy('sosa.majs_i_id') |
| 471 | - ->havingRaw('COUNT(' . $table_prefix . 'sosa.majs_sosa) > 1') // Limit to the duplicate sosas. |
|
| 472 | - ->orderByRaw('COUNT(' . $table_prefix . 'sosa.majs_sosa) DESC, MIN(' . $table_prefix . 'sosa.majs_sosa) ASC') //@phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 470 | + ->havingRaw('COUNT('.$table_prefix.'sosa.majs_sosa) > 1') // Limit to the duplicate sosas. |
|
| 471 | + ->orderByRaw('COUNT('.$table_prefix.'sosa.majs_sosa) DESC, MIN('.$table_prefix.'sosa.majs_sosa) ASC') //@phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 473 | 472 | ->limit($limit + 1) // We want to select one more than required, for ties |
| 474 | 473 | ->get(); |
| 475 | 474 | |
| 476 | 475 | if ($multiple_ancestors->count() > $limit) { |
| 477 | 476 | $last_count = $multiple_ancestors->last()->sosa_count; |
| 478 | 477 | $multiple_ancestors = $multiple_ancestors->reject( |
| 479 | - fn (stdClass $element): bool => $element->sosa_count === $last_count |
|
| 478 | + fn(stdClass $element): bool => $element->sosa_count === $last_count |
|
| 480 | 479 | ); |
| 481 | 480 | } |
| 482 | 481 | return $multiple_ancestors; |
@@ -527,7 +526,7 @@ discard block |
||
| 527 | 526 | ->rightJoinSub( |
| 528 | 527 | $consolidated_ancestors_branches, |
| 529 | 528 | 'indi_branch_consolidated', |
| 530 | - function (JoinClause $join) use ($gen): void { |
|
| 529 | + function(JoinClause $join) use ($gen): void { |
|
| 531 | 530 | $join->where('maj_sosa.majs_gedcom_id', '=', $this->tree->id()) |
| 532 | 531 | ->where('maj_sosa.majs_user_id', '=', $this->user->id()) |
| 533 | 532 | ->where('branches', '>', 0) |