@@ -86,11 +86,10 @@ |
||
86 | 86 | $max_gen_system = app(SosaRecordsService::class)->maxSystemGenerations(); |
87 | 87 | foreach ($users_root as $key => $user_root) { |
88 | 88 | $users_root[$key]['max_gen'] = is_numeric($user_root['max_gen']) ? |
89 | - (int) $user_root['max_gen'] : |
|
90 | - $max_gen_system; |
|
89 | + (int)$user_root['max_gen'] : $max_gen_system; |
|
91 | 90 | }; |
92 | 91 | |
93 | - return $this->viewResponse($this->module->name() . '::config-page', [ |
|
92 | + return $this->viewResponse($this->module->name().'::config-page', [ |
|
94 | 93 | 'module_name' => $this->module->name(), |
95 | 94 | 'title' => I18N::translate('Sosa Configuration'), |
96 | 95 | 'tree' => $tree, |
@@ -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) |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | public function boot(): void |
70 | 70 | { |
71 | 71 | $this->traitBoot(); |
72 | - View::registerCustomView('::modules/privacy-policy/page', $this->name() . '::privacy-policy'); |
|
72 | + View::registerCustomView('::modules/privacy-policy/page', $this->name().'::privacy-policy'); |
|
73 | 73 | |
74 | - if ((int) $this->getPreference('MAJ_USE_LEGACY_XREF') === 1) { |
|
74 | + if ((int)$this->getPreference('MAJ_USE_LEGACY_XREF') === 1) { |
|
75 | 75 | Registry::xrefFactory(new LegacyXrefFactory()); |
76 | 76 | } |
77 | 77 | } |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function loadRoutes(Map $router): void |
84 | 84 | { |
85 | - $router->attach('', '', static function (Map $router): void { |
|
85 | + $router->attach('', '', static function(Map $router): void { |
|
86 | 86 | |
87 | - $router->attach('', '/module-maj/misc', static function (Map $router): void { |
|
87 | + $router->attach('', '/module-maj/misc', static function(Map $router): void { |
|
88 | 88 | |
89 | - $router->attach('', '/config/admin', static function (Map $router): void { |
|
89 | + $router->attach('', '/config/admin', static function(Map $router): void { |
|
90 | 90 | |
91 | 91 | $router->get(AdminConfigPage::class, '', AdminConfigPage::class); |
92 | 92 | $router->post(AdminConfigAction::class, '', AdminConfigAction::class); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | public function listSubscribedHooks(): array |
121 | 121 | { |
122 | 122 | return [ |
123 | - app()->makeWith(TitlesCardHook::class, [ 'module' => $this ]) |
|
123 | + app()->makeWith(TitlesCardHook::class, ['module' => $this]) |
|
124 | 124 | ]; |
125 | 125 | } |
126 | 126 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | ); |
62 | 62 | $this->module->setPreference( |
63 | 63 | 'MAJ_DISPLAY_CNIL', |
64 | - (string) Validator::parsedBody($request)->integer('MAJ_DISPLAY_CNIL', 0) |
|
64 | + (string)Validator::parsedBody($request)->integer('MAJ_DISPLAY_CNIL', 0) |
|
65 | 65 | ); |
66 | 66 | $this->module->setPreference( |
67 | 67 | 'MAJ_CNIL_REFERENCE', |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | ); |
70 | 70 | $this->module->setPreference( |
71 | 71 | 'MAJ_USE_LEGACY_XREF', |
72 | - (string) Validator::parsedBody($request)->integer('MAJ_USE_LEGACY_XREF', 0) |
|
72 | + (string)Validator::parsedBody($request)->integer('MAJ_USE_LEGACY_XREF', 0) |
|
73 | 73 | ); |
74 | 74 | |
75 | 75 | FlashMessages::addMessage( |
@@ -65,7 +65,7 @@ |
||
65 | 65 | public function recordNameAppend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
66 | 66 | { |
67 | 67 | if ($use_long && $record instanceof Individual) { |
68 | - return view($this->module()->name() . '::hooks/name-append', [ |
|
68 | + return view($this->module()->name().'::hooks/name-append', [ |
|
69 | 69 | 'module_name' => $this->module()->name(), |
70 | 70 | 'source_status_service' => $this->source_status_service, |
71 | 71 | 'individual' => $record, |
@@ -47,7 +47,7 @@ |
||
47 | 47 | */ |
48 | 48 | private function extractCitations(Fact $fact) |
49 | 49 | { |
50 | - $extract_regex = '/\n(2 SOUR @(' . Gedcom::REGEX_XREF . ')@(?:\n[3-9] .*)*)/'; |
|
50 | + $extract_regex = '/\n(2 SOUR @('.Gedcom::REGEX_XREF.')@(?:\n[3-9] .*)*)/'; |
|
51 | 51 | preg_match_all($extract_regex, $fact->gedcom(), $matches, PREG_SET_ORDER); |
52 | 52 | $citations = []; |
53 | 53 | foreach ($matches as $match) { |