@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | $view = $this->geoview_data_service->find($tree, $view_id); |
| 83 | 83 | |
| 84 | 84 | $map = $this->map_definition_service->find(Validator::parsedBody($request)->string('map_adapter_map', '')); |
| 85 | - $mapping_property = Validator::parsedBody($request)->string('map_adapter_property_selected', ''); |
|
| 85 | + $mapping_property = Validator::parsedBody($request)->string('map_adapter_property_selected', ''); |
|
| 86 | 86 | |
| 87 | 87 | $mapper = null; |
| 88 | 88 | try { |
@@ -113,14 +113,14 @@ discard block |
||
| 113 | 113 | 'success' |
| 114 | 114 | ); |
| 115 | 115 | //phpcs:ignore Generic.Files.LineLength.TooLong |
| 116 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $new_adapter_id . '” has been added.'); |
|
| 116 | + Log::addConfigurationLog('Module '.$this->module->title().' : Map Adapter “'.$new_adapter_id.'” has been added.'); |
|
| 117 | 117 | } else { |
| 118 | 118 | FlashMessages::addMessage( |
| 119 | 119 | I18N::translate('An error occured while adding a new map configuration.'), |
| 120 | 120 | 'danger' |
| 121 | 121 | ); |
| 122 | 122 | //phpcs:ignore Generic.Files.LineLength.TooLong |
| 123 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter could not be added. See error log.'); |
|
| 123 | + Log::addConfigurationLog('Module '.$this->module->title().' : Map Adapter could not be added. See error log.'); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | return Registry::responseFactory()->redirect(GeoAnalysisViewEditPage::class, [ |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | { |
| 64 | 64 | return [ |
| 65 | 65 | 'topPlaces' => $this->topPlaces() |
| 66 | - ->map(fn(Place $place): array => [ $place->tree()->id(), $place->gedcomName() ]) |
|
| 66 | + ->map(fn(Place $place): array => [$place->tree()->id(), $place->gedcomName()]) |
|
| 67 | 67 | ->toArray() |
| 68 | 68 | ]; |
| 69 | 69 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | ->filter( |
| 87 | 87 | /** @psalm-suppress MissingClosureParamType */ |
| 88 | 88 | fn($item): bool => is_array($item) && count($item) === 2 |
| 89 | - )->map(function (array $item): ?Place { |
|
| 89 | + )->map(function(array $item): ?Place { |
|
| 90 | 90 | try { |
| 91 | 91 | return new Place($item[1], $this->tree_service->find($item[0])); |
| 92 | 92 | } catch (RuntimeException $ex) { |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public function configContent(ModuleInterface $module, Tree $tree): string |
| 108 | 108 | { |
| 109 | - return view($module->name() . '::mappers/filtered-top-config', [ |
|
| 109 | + return view($module->name().'::mappers/filtered-top-config', [ |
|
| 110 | 110 | 'tree' => $tree, |
| 111 | 111 | 'top_places' => $this->topPlaces() |
| 112 | 112 | ]); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | $top_places = Validator::parsedBody($request)->array('mapper_filt_top_places'); |
| 129 | 129 | $config = ['topPlaces' => []]; |
| 130 | 130 | foreach ($top_places as $top_place_id) { |
| 131 | - $place = Place::find((int) $top_place_id, $tree); |
|
| 131 | + $place = Place::find((int)$top_place_id, $tree); |
|
| 132 | 132 | if (mb_strlen($place->gedcomName()) > 0) { |
| 133 | 133 | $config['topPlaces'][] = $place; |
| 134 | 134 | } |
@@ -59,24 +59,24 @@ |
||
| 59 | 59 | $initial = Validator::attributes($request)->string('alpha', ''); |
| 60 | 60 | |
| 61 | 61 | $initials_list = collect($this->module->surnameAlpha($tree, false, false, I18N::locale())) |
| 62 | - ->reject(function (int $count, string $initial): bool { |
|
| 62 | + ->reject(function(int $count, string $initial): bool { |
|
| 63 | 63 | return $initial === '@' || $initial === ','; |
| 64 | 64 | }); |
| 65 | 65 | |
| 66 | 66 | $show_all = Validator::queryParams($request)->string('show_all', 'no'); |
| 67 | 67 | |
| 68 | 68 | if ($show_all === 'yes') { |
| 69 | - $title = I18N::translate('Patronymic Lineages') . ' — ' . I18N::translate('All'); |
|
| 69 | + $title = I18N::translate('Patronymic Lineages').' — '.I18N::translate('All'); |
|
| 70 | 70 | $surnames = $this->module->surnames($tree, '', '', false, false, I18N::locale()); |
| 71 | 71 | } elseif (mb_strlen($initial) === 1) { |
| 72 | - $title = I18N::translate('Patronymic Lineages') . ' — ' . $initial; |
|
| 72 | + $title = I18N::translate('Patronymic Lineages').' — '.$initial; |
|
| 73 | 73 | $surnames = $this->module->surnames($tree, '', $initial, false, false, I18N::locale()); |
| 74 | 74 | } else { |
| 75 | - $title = I18N::translate('Patronymic Lineages'); |
|
| 75 | + $title = I18N::translate('Patronymic Lineages'); |
|
| 76 | 76 | $surnames = []; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - return $this->viewResponse($this->module->name() . '::surnames-page', [ |
|
| 79 | + return $this->viewResponse($this->module->name().'::surnames-page', [ |
|
| 80 | 80 | 'title' => $title, |
| 81 | 81 | 'module' => $this->module, |
| 82 | 82 | 'tree' => $tree, |
@@ -101,7 +101,7 @@ |
||
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - return $root_lineages->sort(function (LineageRootNode $a, LineageRootNode $b) { |
|
| 104 | + return $root_lineages->sort(function(LineageRootNode $a, LineageRootNode $b) { |
|
| 105 | 105 | if ($a->numberChildNodes() === $b->numberChildNodes()) { |
| 106 | 106 | return 0; |
| 107 | 107 | } |
@@ -100,7 +100,7 @@ |
||
| 100 | 100 | return Registry::responseFactory()->redirect(TreePage::class, ['tree' => $tree->name()]); |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - return $this->viewResponse($this->module->name() . '::certificate-page', [ |
|
| 103 | + return $this->viewResponse($this->module->name().'::certificate-page', [ |
|
| 104 | 104 | 'title' => I18N::translate('Certificate - %s', $certificate->name()), |
| 105 | 105 | 'tree' => $tree, |
| 106 | 106 | 'module_name' => $this->module->name(), |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $user = $user_id === -1 ? new DefaultUser() : $this->user_service->find($user_id); |
| 59 | 59 | |
| 60 | 60 | /** @var SosaCalculatorService $sosa_calc_service */ |
| 61 | - $sosa_calc_service = app()->makeWith(SosaCalculatorService::class, [ 'tree' => $tree, 'user' => $user]); |
|
| 61 | + $sosa_calc_service = app()->makeWith(SosaCalculatorService::class, ['tree' => $tree, 'user' => $user]); |
|
| 62 | 62 | |
| 63 | 63 | if ( |
| 64 | 64 | $partial_from !== '' && |
@@ -70,8 +70,7 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | return $res ? |
| 73 | - Registry::responseFactory()->response() : |
|
| 74 | - Registry::responseFactory()->response( |
|
| 73 | + Registry::responseFactory()->response() : Registry::responseFactory()->response( |
|
| 75 | 74 | I18N::translate('An error occurred while computing Sosa ancestors.'), |
| 76 | 75 | StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR |
| 77 | 76 | ); |
@@ -65,7 +65,7 @@ |
||
| 65 | 65 | $user = $user_id === -1 ? new DefaultUser() : $this->user_service->find($user_id); |
| 66 | 66 | if ($user !== null && ($root_indi = Registry::individualFactory()->make($root_id, $tree)) !== null) { |
| 67 | 67 | $tree->setUserPreference($user, 'MAJ_SOSA_ROOT_ID', $root_indi->xref()); |
| 68 | - $tree->setUserPreference($user, 'MAJ_SOSA_MAX_GEN', (string) $max_gen); |
|
| 68 | + $tree->setUserPreference($user, 'MAJ_SOSA_MAX_GEN', (string)$max_gen); |
|
| 69 | 69 | FlashMessages::addMessage(I18N::translate('The root individual has been updated.')); |
| 70 | 70 | return Registry::responseFactory()->redirect(SosaConfig::class, [ |
| 71 | 71 | 'tree' => $tree->name(), |
@@ -100,7 +100,7 @@ |
||
| 100 | 100 | public function jsonDeserialize($config): self |
| 101 | 101 | { |
| 102 | 102 | if (is_string($config)) { |
| 103 | - return $this->jsonDeserialize((array) json_decode($config)); |
|
| 103 | + return $this->jsonDeserialize((array)json_decode($config)); |
|
| 104 | 104 | } |
| 105 | 105 | if (is_array($config)) { |
| 106 | 106 | return $this->setConfig($config); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function maxGeneration(): int |
| 76 | 76 | { |
| 77 | - return (int) DB::table('maj_sosa') |
|
| 77 | + return (int)DB::table('maj_sosa') |
|
| 78 | 78 | ->where('majs_gedcom_id', '=', $this->tree->id()) |
| 79 | 79 | ->where('majs_user_id', '=', $this->user->id()) |
| 80 | 80 | ->max('majs_gen'); |
@@ -152,8 +152,7 @@ discard block |
||
| 152 | 152 | ->get()->first(); |
| 153 | 153 | |
| 154 | 154 | $denom = $row->n * $row->sum_x2 - pow($row->sum_x, 2); |
| 155 | - return ((int) $row->n === 0 || $denom === 0) ? 0 : |
|
| 156 | - -($row->n * $row->sum_xy - $row->sum_x * $row->sum_y) / $denom; |
|
| 155 | + return ((int)$row->n === 0 || $denom === 0) ? 0 : -($row->n * $row->sum_xy - $row->sum_x * $row->sum_y) / $denom; |
|
| 157 | 156 | } |
| 158 | 157 | |
| 159 | 158 | /** |
@@ -177,10 +176,10 @@ discard block |
||
| 177 | 176 | |
| 178 | 177 | $statistics_by_gen = []; |
| 179 | 178 | foreach ($stats_by_gen as $gen => $stats_gen) { |
| 180 | - $statistics_by_gen[(int) $stats_gen->gen] = array( |
|
| 181 | - 'sosaCount' => (int) $stats_gen->total_sosa, |
|
| 182 | - 'sosaTotalCount' => (int) $cumul_stats_by_gen[$gen]->total_cumul, |
|
| 183 | - 'diffSosaTotalCount' => (int) $cumul_stats_by_gen[$gen]->total_distinct_cumul, |
|
| 179 | + $statistics_by_gen[(int)$stats_gen->gen] = array( |
|
| 180 | + 'sosaCount' => (int)$stats_gen->total_sosa, |
|
| 181 | + 'sosaTotalCount' => (int)$cumul_stats_by_gen[$gen]->total_cumul, |
|
| 182 | + 'diffSosaTotalCount' => (int)$cumul_stats_by_gen[$gen]->total_distinct_cumul, |
|
| 184 | 183 | 'firstBirth' => $stats_gen->first_year, |
| 185 | 184 | 'firstEstimatedBirth' => $stats_gen->first_est_year, |
| 186 | 185 | 'lastBirth' => $stats_gen->last_year, |
@@ -224,7 +223,7 @@ discard block |
||
| 224 | 223 | ->where('majs_user_id', '=', $this->user->id()); |
| 225 | 224 | |
| 226 | 225 | return DB::table('maj_sosa') |
| 227 | - ->joinSub($list_gen, 'list_gen', function (JoinClause $join): void { |
|
| 226 | + ->joinSub($list_gen, 'list_gen', function(JoinClause $join): void { |
|
| 228 | 227 | $join->on('maj_sosa.majs_gen', '<=', 'list_gen.majs_gen') |
| 229 | 228 | ->where('majs_gedcom_id', '=', $this->tree->id()) |
| 230 | 229 | ->where('majs_user_id', '=', $this->user->id()); |
@@ -265,37 +264,37 @@ discard block |
||
| 265 | 264 | ->select(['list_gen.majs_gen AS gen', 'sosa.majs_gedcom_id', 'sosa.majs_user_id']) |
| 266 | 265 | ->addSelect(['sosa.majs_i_id', 'sosa.majs_gen']) |
| 267 | 266 | ->selectRaw( |
| 268 | - '(CASE ' . |
|
| 269 | - ' WHEN ' . $table_prefix . 'sosa_fat.majs_i_id IS NULL' . |
|
| 270 | - ' THEN POWER(2, ' . $table_prefix . 'list_gen.majs_gen - ' . $table_prefix . 'sosa.majs_gen - 1)' . |
|
| 271 | - ' ELSE 0 ' . |
|
| 272 | - ' END)' . |
|
| 273 | - ' + (CASE ' . |
|
| 274 | - ' WHEN ' . $table_prefix . 'sosa_mot.majs_i_id IS NULL' . |
|
| 275 | - ' THEN POWER(2, ' . $table_prefix . 'list_gen.majs_gen - ' . $table_prefix . 'sosa.majs_gen - 1)' . |
|
| 276 | - ' ELSE 0 ' . |
|
| 267 | + '(CASE '. |
|
| 268 | + ' WHEN '.$table_prefix.'sosa_fat.majs_i_id IS NULL'. |
|
| 269 | + ' THEN POWER(2, '.$table_prefix.'list_gen.majs_gen - '.$table_prefix.'sosa.majs_gen - 1)'. |
|
| 270 | + ' ELSE 0 '. |
|
| 271 | + ' END)'. |
|
| 272 | + ' + (CASE '. |
|
| 273 | + ' WHEN '.$table_prefix.'sosa_mot.majs_i_id IS NULL'. |
|
| 274 | + ' THEN POWER(2, '.$table_prefix.'list_gen.majs_gen - '.$table_prefix.'sosa.majs_gen - 1)'. |
|
| 275 | + ' ELSE 0 '. |
|
| 277 | 276 | ' END) contrib' |
| 278 | 277 | ) |
| 279 | - ->joinSub($list_gen, 'list_gen', function (JoinClause $join): void { |
|
| 278 | + ->joinSub($list_gen, 'list_gen', function(JoinClause $join): void { |
|
| 280 | 279 | $join->on('sosa.majs_gen', '<', 'list_gen.majs_gen') |
| 281 | 280 | ->where('majs_gedcom_id', '=', $this->tree->id()) |
| 282 | 281 | ->where('majs_user_id', '=', $this->user->id()); |
| 283 | 282 | }) |
| 284 | - ->leftJoin('maj_sosa AS sosa_fat', function (JoinClause $join) use ($table_prefix): void { |
|
| 283 | + ->leftJoin('maj_sosa AS sosa_fat', function(JoinClause $join) use ($table_prefix): void { |
|
| 285 | 284 | // Link to sosa's father |
| 286 | - $join->whereRaw($table_prefix . 'sosa_fat.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa') |
|
| 285 | + $join->whereRaw($table_prefix.'sosa_fat.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa') |
|
| 287 | 286 | ->where('sosa_fat.majs_gedcom_id', '=', $this->tree->id()) |
| 288 | 287 | ->where('sosa_fat.majs_user_id', '=', $this->user->id()); |
| 289 | 288 | }) |
| 290 | - ->leftJoin('maj_sosa AS sosa_mot', function (JoinClause $join) use ($table_prefix): void { |
|
| 289 | + ->leftJoin('maj_sosa AS sosa_mot', function(JoinClause $join) use ($table_prefix): void { |
|
| 291 | 290 | // Link to sosa's mother |
| 292 | - $join->whereRaw($table_prefix . 'sosa_mot.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa + 1') |
|
| 291 | + $join->whereRaw($table_prefix.'sosa_mot.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa + 1') |
|
| 293 | 292 | ->where('sosa_mot.majs_gedcom_id', '=', $this->tree->id()) |
| 294 | 293 | ->where('sosa_mot.majs_user_id', '=', $this->user->id()); |
| 295 | 294 | }) |
| 296 | 295 | ->where('sosa.majs_gedcom_id', '=', $this->tree->id()) |
| 297 | 296 | ->where('sosa.majs_user_id', '=', $this->user->id()) |
| 298 | - ->where(function (Builder $query): void { |
|
| 297 | + ->where(function(Builder $query): void { |
|
| 299 | 298 | $query->whereNull('sosa_fat.majs_i_id') |
| 300 | 299 | ->orWhereNull('sosa_mot.majs_i_id'); |
| 301 | 300 | }); |
@@ -305,24 +304,24 @@ discard block |
||
| 305 | 304 | */ |
| 306 | 305 | $non_roots_ancestors = DB::table('maj_sosa AS sosa') |
| 307 | 306 | ->select(['sosa.majs_gen', 'sosa.majs_gedcom_id', 'sosa.majs_user_id', 'sosa.majs_sosa']) |
| 308 | - ->selectRaw('MAX(' . $table_prefix . 'sosa_anc.majs_sosa) - MIN(' . $table_prefix . 'sosa_anc.majs_sosa)' . |
|
| 307 | + ->selectRaw('MAX('.$table_prefix.'sosa_anc.majs_sosa) - MIN('.$table_prefix.'sosa_anc.majs_sosa)'. |
|
| 309 | 308 | ' AS full_ancestors') |
| 310 | - ->join('maj_sosa AS sosa_anc', function (JoinClause $join) use ($table_prefix): void { |
|
| 309 | + ->join('maj_sosa AS sosa_anc', function(JoinClause $join) use ($table_prefix): void { |
|
| 311 | 310 | $join->on('sosa.majs_gen', '<', 'sosa_anc.majs_gen') |
| 312 | - ->whereRaw('FLOOR(' . $table_prefix . 'sosa_anc.majs_sosa / POWER(2, ' . |
|
| 313 | - $table_prefix . 'sosa_anc.majs_gen - ' . $table_prefix . 'sosa.majs_gen)) = ' . |
|
| 314 | - $table_prefix . 'sosa.majs_sosa') |
|
| 311 | + ->whereRaw('FLOOR('.$table_prefix.'sosa_anc.majs_sosa / POWER(2, '. |
|
| 312 | + $table_prefix.'sosa_anc.majs_gen - '.$table_prefix.'sosa.majs_gen)) = '. |
|
| 313 | + $table_prefix.'sosa.majs_sosa') |
|
| 315 | 314 | ->where('sosa_anc.majs_gedcom_id', '=', $this->tree->id()) |
| 316 | 315 | ->where('sosa_anc.majs_user_id', '=', $this->user->id()); |
| 317 | 316 | }) |
| 318 | 317 | ->where('sosa.majs_gedcom_id', '=', $this->tree->id()) |
| 319 | 318 | ->where('sosa.majs_user_id', '=', $this->user->id()) |
| 320 | - ->whereIn('sosa_anc.majs_i_id', function (Builder $query) use ($table_prefix): void { |
|
| 319 | + ->whereIn('sosa_anc.majs_i_id', function(Builder $query) use ($table_prefix): void { |
|
| 321 | 320 | $query->from('maj_sosa AS sosa_gen') |
| 322 | 321 | ->select('sosa_gen.majs_i_id')->distinct() |
| 323 | 322 | ->where('sosa_gen.majs_gedcom_id', '=', $this->tree->id()) |
| 324 | 323 | ->where('sosa_gen.majs_user_id', '=', $this->user->id()) |
| 325 | - ->whereRaw($table_prefix . 'sosa_gen.majs_gen = ' . $table_prefix . 'sosa.majs_gen'); |
|
| 324 | + ->whereRaw($table_prefix.'sosa_gen.majs_gen = '.$table_prefix.'sosa.majs_gen'); |
|
| 326 | 325 | }) |
| 327 | 326 | ->groupBy(['sosa.majs_gen', 'sosa.majs_gedcom_id', 'sosa.majs_user_id', |
| 328 | 327 | 'sosa.majs_sosa', 'sosa.majs_i_id']); |
@@ -335,7 +334,7 @@ discard block |
||
| 335 | 334 | ->select(['sosa.majs_gen AS gen', 'sosa.majs_gedcom_id', 'sosa.majs_user_id']) |
| 336 | 335 | ->addSelect(['sosa.majs_i_id', 'sosa.majs_gen']) |
| 337 | 336 | ->selectRaw('1 AS contrib') |
| 338 | - ->leftJoinSub($non_roots_ancestors, 'nonroot', function (JoinClause $join): void { |
|
| 337 | + ->leftJoinSub($non_roots_ancestors, 'nonroot', function(JoinClause $join): void { |
|
| 339 | 338 | $join->on('sosa.majs_gen', '=', 'nonroot.majs_gen') |
| 340 | 339 | ->on('sosa.majs_sosa', '=', 'nonroot.majs_sosa') |
| 341 | 340 | ->where('nonroot.full_ancestors', '>', 0) |
@@ -353,9 +352,9 @@ discard block |
||
| 353 | 352 | ->fromSub($root_ancestors_contributions->unionAll($known_ancestors_contributions), 'sosa_contribs') |
| 354 | 353 | ->select(['sosa_contribs.gen', 'sosa_contribs.majs_gedcom_id', 'sosa_contribs.majs_user_id']) |
| 355 | 354 | ->addSelect(['sosa_contribs.majs_i_id', 'sosa_contribs.contrib']) |
| 356 | - ->selectRaw('COUNT(' . $table_prefix . 'sosa_contribs.majs_i_id) * ' . |
|
| 357 | - $table_prefix . 'sosa_contribs.contrib AS totalContrib') |
|
| 358 | - ->leftJoin('maj_sosa AS sosa_low', function (JoinClause $join): void { |
|
| 355 | + ->selectRaw('COUNT('.$table_prefix.'sosa_contribs.majs_i_id) * '. |
|
| 356 | + $table_prefix.'sosa_contribs.contrib AS totalContrib') |
|
| 357 | + ->leftJoin('maj_sosa AS sosa_low', function(JoinClause $join): void { |
|
| 359 | 358 | $join->on('sosa_low.majs_gen', '<', 'sosa_contribs.majs_gen') |
| 360 | 359 | ->on('sosa_low.majs_i_id', '=', 'sosa_contribs.majs_i_id') |
| 361 | 360 | ->where('sosa_low.majs_gedcom_id', '=', $this->tree->id()) |
@@ -376,9 +375,9 @@ discard block |
||
| 376 | 375 | |
| 377 | 376 | $pedi_collapse_by_gen = []; |
| 378 | 377 | foreach ($pedi_collapse_coll as $collapse_gen) { |
| 379 | - $pedi_collapse_by_gen[(int) $collapse_gen->gen] = array( |
|
| 380 | - 'pedi_collapse_roots' => (float) $collapse_gen->pedi_collapse_roots, |
|
| 381 | - 'pedi_collapse_xgen' => (float) $collapse_gen->pedi_collapse_xgen |
|
| 378 | + $pedi_collapse_by_gen[(int)$collapse_gen->gen] = array( |
|
| 379 | + 'pedi_collapse_roots' => (float)$collapse_gen->pedi_collapse_roots, |
|
| 380 | + 'pedi_collapse_xgen' => (float)$collapse_gen->pedi_collapse_xgen |
|
| 382 | 381 | ); |
| 383 | 382 | } |
| 384 | 383 | return $pedi_collapse_by_gen; |
@@ -410,26 +409,26 @@ discard block |
||
| 410 | 409 | |
| 411 | 410 | $table_prefix = DB::connection()->getTablePrefix(); |
| 412 | 411 | $missing_ancestors_by_gen = DB::table('maj_sosa AS sosa') |
| 413 | - ->selectRaw($table_prefix . 'sosa.majs_gen - ? AS majs_gen_norm', [$gen]) |
|
| 414 | - ->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 |
|
| 415 | - ->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 |
|
| 416 | - ->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 |
|
| 417 | - ->leftJoin('maj_sosa AS sosa_fat', function (JoinClause $join) use ($table_prefix): void { |
|
| 412 | + ->selectRaw($table_prefix.'sosa.majs_gen - ? AS majs_gen_norm', [$gen]) |
|
| 413 | + ->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 |
|
| 414 | + ->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 |
|
| 415 | + ->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 |
|
| 416 | + ->leftJoin('maj_sosa AS sosa_fat', function(JoinClause $join) use ($table_prefix): void { |
|
| 418 | 417 | // Link to sosa's father |
| 419 | - $join->whereRaw($table_prefix . 'sosa_fat.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa') |
|
| 418 | + $join->whereRaw($table_prefix.'sosa_fat.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa') |
|
| 420 | 419 | ->where('sosa_fat.majs_gedcom_id', '=', $this->tree->id()) |
| 421 | 420 | ->where('sosa_fat.majs_user_id', '=', $this->user->id()); |
| 422 | 421 | }) |
| 423 | - ->leftJoin('maj_sosa AS sosa_mot', function (JoinClause $join) use ($table_prefix): void { |
|
| 422 | + ->leftJoin('maj_sosa AS sosa_mot', function(JoinClause $join) use ($table_prefix): void { |
|
| 424 | 423 | // Link to sosa's mother |
| 425 | - $join->whereRaw($table_prefix . 'sosa_mot.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa + 1') |
|
| 424 | + $join->whereRaw($table_prefix.'sosa_mot.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa + 1') |
|
| 426 | 425 | ->where('sosa_mot.majs_gedcom_id', '=', $this->tree->id()) |
| 427 | 426 | ->where('sosa_mot.majs_user_id', '=', $this->user->id()); |
| 428 | 427 | }) |
| 429 | 428 | ->where('sosa.majs_gedcom_id', '=', $this->tree->id()) |
| 430 | 429 | ->where('sosa.majs_user_id', '=', $this->user->id()) |
| 431 | 430 | ->where('sosa.majs_gen', '>=', $gen) |
| 432 | - ->where(function (Builder $query): void { |
|
| 431 | + ->where(function(Builder $query): void { |
|
| 433 | 432 | $query->whereNull('sosa_fat.majs_i_id') |
| 434 | 433 | ->orWhereNull('sosa_mot.majs_i_id'); |
| 435 | 434 | }) |
@@ -438,11 +437,11 @@ discard block |
||
| 438 | 437 | return DB::table('maj_sosa AS sosa_list') |
| 439 | 438 | ->select(['stats_by_gen.root_ancestor AS root_ancestor_sosa', 'sosa_list.majs_i_id as root_ancestor_id']) |
| 440 | 439 | ->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 |
| 441 | - ->selectRaw(' SQRT(' . |
|
| 442 | - ' 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 |
|
| 443 | - ' - 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 |
|
| 440 | + ->selectRaw(' SQRT('. |
|
| 441 | + ' 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 |
|
| 442 | + ' - 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 |
|
| 444 | 443 | ' ) AS stddev_gen_depth') |
| 445 | - ->joinSub($missing_ancestors_by_gen, 'stats_by_gen', function (JoinClause $join): void { |
|
| 444 | + ->joinSub($missing_ancestors_by_gen, 'stats_by_gen', function(JoinClause $join): void { |
|
| 446 | 445 | $join->on('sosa_list.majs_sosa', '=', 'stats_by_gen.root_ancestor') |
| 447 | 446 | ->where('sosa_list.majs_gedcom_id', '=', $this->tree->id()) |
| 448 | 447 | ->where('sosa_list.majs_user_id', '=', $this->user->id()); |
@@ -471,16 +470,16 @@ discard block |
||
| 471 | 470 | $table_prefix = DB::connection()->getTablePrefix(); |
| 472 | 471 | $multiple_ancestors = DB::table('maj_sosa AS sosa') |
| 473 | 472 | ->select('sosa.majs_i_id AS sosa_i_id') |
| 474 | - ->selectRaw('COUNT(' . $table_prefix . 'sosa.majs_sosa) AS sosa_count') |
|
| 475 | - ->leftJoin('maj_sosa AS sosa_fat', function (JoinClause $join) use ($table_prefix): void { |
|
| 473 | + ->selectRaw('COUNT('.$table_prefix.'sosa.majs_sosa) AS sosa_count') |
|
| 474 | + ->leftJoin('maj_sosa AS sosa_fat', function(JoinClause $join) use ($table_prefix): void { |
|
| 476 | 475 | // Link to sosa's father |
| 477 | - $join->whereRaw($table_prefix . 'sosa_fat.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa') |
|
| 476 | + $join->whereRaw($table_prefix.'sosa_fat.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa') |
|
| 478 | 477 | ->where('sosa_fat.majs_gedcom_id', '=', $this->tree->id()) |
| 479 | 478 | ->where('sosa_fat.majs_user_id', '=', $this->user->id()); |
| 480 | 479 | }) |
| 481 | - ->leftJoin('maj_sosa AS sosa_mot', function (JoinClause $join) use ($table_prefix): void { |
|
| 480 | + ->leftJoin('maj_sosa AS sosa_mot', function(JoinClause $join) use ($table_prefix): void { |
|
| 482 | 481 | // Link to sosa's mother |
| 483 | - $join->whereRaw($table_prefix . 'sosa_mot.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa + 1') |
|
| 482 | + $join->whereRaw($table_prefix.'sosa_mot.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa + 1') |
|
| 484 | 483 | ->where('sosa_mot.majs_gedcom_id', '=', $this->tree->id()) |
| 485 | 484 | ->where('sosa_mot.majs_user_id', '=', $this->user->id()); |
| 486 | 485 | }) |
@@ -489,15 +488,15 @@ discard block |
||
| 489 | 488 | ->whereNull('sosa_fat.majs_sosa') // We keep only root individuals, i.e. those with no father or mother |
| 490 | 489 | ->whereNull('sosa_mot.majs_sosa') |
| 491 | 490 | ->groupBy('sosa.majs_i_id') |
| 492 | - ->havingRaw('COUNT(' . $table_prefix . 'sosa.majs_sosa) > 1') // Limit to the duplicate sosas. |
|
| 493 | - ->orderByRaw('COUNT(' . $table_prefix . 'sosa.majs_sosa) DESC, MIN(' . $table_prefix . 'sosa.majs_sosa) ASC') //@phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 491 | + ->havingRaw('COUNT('.$table_prefix.'sosa.majs_sosa) > 1') // Limit to the duplicate sosas. |
|
| 492 | + ->orderByRaw('COUNT('.$table_prefix.'sosa.majs_sosa) DESC, MIN('.$table_prefix.'sosa.majs_sosa) ASC') //@phpcs:ignore Generic.Files.LineLength.TooLong |
|
| 494 | 493 | ->limit($limit + 1) // We want to select one more than required, for ties |
| 495 | 494 | ->get(); |
| 496 | 495 | |
| 497 | 496 | if ($multiple_ancestors->count() > $limit) { |
| 498 | 497 | $last_count = $multiple_ancestors->last()->sosa_count; |
| 499 | 498 | $multiple_ancestors = $multiple_ancestors->reject( |
| 500 | - fn (stdClass $element): bool => $element->sosa_count === $last_count |
|
| 499 | + fn (stdClass $element): bool => $element->sosa_count === $last_count |
|
| 501 | 500 | ); |
| 502 | 501 | } |
| 503 | 502 | return $multiple_ancestors; |
@@ -552,7 +551,7 @@ discard block |
||
| 552 | 551 | ->rightJoinSub( |
| 553 | 552 | $consolidated_ancestors_branches, |
| 554 | 553 | 'indi_branch_consolidated', |
| 555 | - function (JoinClause $join) use ($gen): void { |
|
| 554 | + function(JoinClause $join) use ($gen): void { |
|
| 556 | 555 | $join->where('maj_sosa.majs_gedcom_id', '=', $this->tree->id()) |
| 557 | 556 | ->where('maj_sosa.majs_user_id', '=', $this->user->id()) |
| 558 | 557 | ->where('branches', '>', 0) |