@@ -26,51 +26,51 @@ |
||
26 | 26 | */ |
27 | 27 | class SosaIconHook implements RecordNameTextExtenderInterface |
28 | 28 | { |
29 | - private ModuleInterface $module; |
|
30 | - private SosaRecordsService $sosa_records_service; |
|
29 | + private ModuleInterface $module; |
|
30 | + private SosaRecordsService $sosa_records_service; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Constructor for SosaIconHook |
|
34 | - * |
|
35 | - * @param ModuleInterface $module |
|
36 | - * @param SosaRecordsService $sosa_records_service |
|
37 | - */ |
|
38 | - public function __construct(ModuleInterface $module, SosaRecordsService $sosa_records_service) |
|
39 | - { |
|
40 | - $this->module = $module; |
|
41 | - $this->sosa_records_service = $sosa_records_service; |
|
42 | - } |
|
32 | + /** |
|
33 | + * Constructor for SosaIconHook |
|
34 | + * |
|
35 | + * @param ModuleInterface $module |
|
36 | + * @param SosaRecordsService $sosa_records_service |
|
37 | + */ |
|
38 | + public function __construct(ModuleInterface $module, SosaRecordsService $sosa_records_service) |
|
39 | + { |
|
40 | + $this->module = $module; |
|
41 | + $this->sosa_records_service = $sosa_records_service; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * {@inheritDoc} |
|
46 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module() |
|
47 | - */ |
|
48 | - public function module(): ModuleInterface |
|
49 | - { |
|
50 | - return $this->module; |
|
51 | - } |
|
44 | + /** |
|
45 | + * {@inheritDoc} |
|
46 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module() |
|
47 | + */ |
|
48 | + public function module(): ModuleInterface |
|
49 | + { |
|
50 | + return $this->module; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * {@inheritDoc} |
|
55 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNamePrepend() |
|
56 | - */ |
|
57 | - public function recordNamePrepend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
|
58 | - { |
|
59 | - return ''; |
|
60 | - } |
|
53 | + /** |
|
54 | + * {@inheritDoc} |
|
55 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNamePrepend() |
|
56 | + */ |
|
57 | + public function recordNamePrepend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
|
58 | + { |
|
59 | + return ''; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * {@inheritDoc} |
|
64 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNameAppend() |
|
65 | - */ |
|
66 | - public function recordNameAppend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
|
67 | - { |
|
68 | - if ( |
|
69 | - $record instanceof Individual && |
|
70 | - $this->sosa_records_service->isSosa($record->tree(), Auth::user(), $record) |
|
71 | - ) { |
|
72 | - return view($this->module->name() . '::icons/sosa', [ 'size_style' => $size ]); |
|
73 | - } |
|
74 | - return ''; |
|
75 | - } |
|
62 | + /** |
|
63 | + * {@inheritDoc} |
|
64 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNameAppend() |
|
65 | + */ |
|
66 | + public function recordNameAppend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
|
67 | + { |
|
68 | + if ( |
|
69 | + $record instanceof Individual && |
|
70 | + $this->sosa_records_service->isSosa($record->tree(), Auth::user(), $record) |
|
71 | + ) { |
|
72 | + return view($this->module->name() . '::icons/sosa', [ 'size_style' => $size ]); |
|
73 | + } |
|
74 | + return ''; |
|
75 | + } |
|
76 | 76 | } |
@@ -69,7 +69,7 @@ |
||
69 | 69 | $record instanceof Individual && |
70 | 70 | $this->sosa_records_service->isSosa($record->tree(), Auth::user(), $record) |
71 | 71 | ) { |
72 | - return view($this->module->name() . '::icons/sosa', [ 'size_style' => $size ]); |
|
72 | + return view($this->module->name().'::icons/sosa', ['size_style' => $size]); |
|
73 | 73 | } |
74 | 74 | return ''; |
75 | 75 | } |
@@ -21,79 +21,79 @@ |
||
21 | 21 | */ |
22 | 22 | class MissingAncestor |
23 | 23 | { |
24 | - /** |
|
25 | - * @var Individual $individual |
|
26 | - */ |
|
27 | - private $individual; |
|
24 | + /** |
|
25 | + * @var Individual $individual |
|
26 | + */ |
|
27 | + private $individual; |
|
28 | 28 | |
29 | - /** |
|
30 | - * @var int $sosa |
|
31 | - */ |
|
32 | - private $sosa; |
|
29 | + /** |
|
30 | + * @var int $sosa |
|
31 | + */ |
|
32 | + private $sosa; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @var bool $missing_father |
|
36 | - */ |
|
37 | - private $missing_father; |
|
34 | + /** |
|
35 | + * @var bool $missing_father |
|
36 | + */ |
|
37 | + private $missing_father; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var bool $missing_mother |
|
41 | - */ |
|
42 | - private $missing_mother; |
|
39 | + /** |
|
40 | + * @var bool $missing_mother |
|
41 | + */ |
|
42 | + private $missing_mother; |
|
43 | 43 | |
44 | - /** |
|
45 | - * Constructor for MissingAncestor data class |
|
46 | - * |
|
47 | - * @param Individual $ancestor |
|
48 | - * @param int $sosa |
|
49 | - * @param bool $missing_father |
|
50 | - * @param bool $missing_mother |
|
51 | - */ |
|
52 | - public function __construct(Individual $ancestor, int $sosa, bool $missing_father, bool $missing_mother) |
|
53 | - { |
|
54 | - $this->individual = $ancestor; |
|
55 | - $this->sosa = $sosa; |
|
56 | - $this->missing_father = $missing_father; |
|
57 | - $this->missing_mother = $missing_mother; |
|
58 | - } |
|
44 | + /** |
|
45 | + * Constructor for MissingAncestor data class |
|
46 | + * |
|
47 | + * @param Individual $ancestor |
|
48 | + * @param int $sosa |
|
49 | + * @param bool $missing_father |
|
50 | + * @param bool $missing_mother |
|
51 | + */ |
|
52 | + public function __construct(Individual $ancestor, int $sosa, bool $missing_father, bool $missing_mother) |
|
53 | + { |
|
54 | + $this->individual = $ancestor; |
|
55 | + $this->sosa = $sosa; |
|
56 | + $this->missing_father = $missing_father; |
|
57 | + $this->missing_mother = $missing_mother; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Reference individual of the row |
|
62 | - * |
|
63 | - * @return Individual |
|
64 | - */ |
|
65 | - public function individual(): Individual |
|
66 | - { |
|
67 | - return $this->individual; |
|
68 | - } |
|
60 | + /** |
|
61 | + * Reference individual of the row |
|
62 | + * |
|
63 | + * @return Individual |
|
64 | + */ |
|
65 | + public function individual(): Individual |
|
66 | + { |
|
67 | + return $this->individual; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Minimum sosa of the reference individual |
|
72 | - * |
|
73 | - * @return int |
|
74 | - */ |
|
75 | - public function sosa(): int |
|
76 | - { |
|
77 | - return $this->sosa; |
|
78 | - } |
|
70 | + /** |
|
71 | + * Minimum sosa of the reference individual |
|
72 | + * |
|
73 | + * @return int |
|
74 | + */ |
|
75 | + public function sosa(): int |
|
76 | + { |
|
77 | + return $this->sosa; |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Indicate whether the reference individual does not have a father |
|
82 | - * |
|
83 | - * @return bool |
|
84 | - */ |
|
85 | - public function isFatherMissing(): bool |
|
86 | - { |
|
87 | - return $this->missing_father; |
|
88 | - } |
|
80 | + /** |
|
81 | + * Indicate whether the reference individual does not have a father |
|
82 | + * |
|
83 | + * @return bool |
|
84 | + */ |
|
85 | + public function isFatherMissing(): bool |
|
86 | + { |
|
87 | + return $this->missing_father; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * Indicate whether the reference individual does not have a mother |
|
92 | - * |
|
93 | - * @return bool |
|
94 | - */ |
|
95 | - public function isMotherMissing(): bool |
|
96 | - { |
|
97 | - return $this->missing_mother; |
|
98 | - } |
|
90 | + /** |
|
91 | + * Indicate whether the reference individual does not have a mother |
|
92 | + * |
|
93 | + * @return bool |
|
94 | + */ |
|
95 | + public function isMotherMissing(): bool |
|
96 | + { |
|
97 | + return $this->missing_mother; |
|
98 | + } |
|
99 | 99 | } |
@@ -35,74 +35,74 @@ |
||
35 | 35 | */ |
36 | 36 | class AncestorsListIndividual implements RequestHandlerInterface |
37 | 37 | { |
38 | - use ViewResponseTrait; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var SosaModule|null $module |
|
42 | - */ |
|
43 | - private $module; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var SosaRecordsService $sosa_record_service |
|
47 | - */ |
|
48 | - private $sosa_record_service; |
|
49 | - |
|
50 | - /** |
|
51 | - * Constructor for AncestorsListIndividual Request Handler |
|
52 | - * |
|
53 | - * @param ModuleService $module_service |
|
54 | - * @param SosaRecordsService $sosa_record_service |
|
55 | - */ |
|
56 | - public function __construct( |
|
57 | - ModuleService $module_service, |
|
58 | - SosaRecordsService $sosa_record_service |
|
59 | - ) { |
|
60 | - $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
61 | - $this->sosa_record_service = $sosa_record_service; |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * {@inheritDoc} |
|
66 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
67 | - */ |
|
68 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
69 | - { |
|
70 | - $this->layout = 'layouts/ajax'; |
|
71 | - |
|
72 | - if ($this->module === null) { |
|
73 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
74 | - } |
|
75 | - |
|
76 | - $tree = $request->getAttribute('tree'); |
|
77 | - assert($tree instanceof Tree); |
|
78 | - |
|
79 | - $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
|
80 | - |
|
81 | - $current_gen = (int) ($request->getAttribute('gen') ?? 0); |
|
82 | - |
|
83 | - if ($current_gen <= 0) { |
|
84 | - return response('Invalid generation', StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY); |
|
85 | - } |
|
86 | - |
|
87 | - $list_ancestors = $this->sosa_record_service->listAncestorsAtGeneration($tree, $user, $current_gen); |
|
88 | - $nb_ancestors_all = $list_ancestors->count(); |
|
89 | - |
|
90 | - /** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Individual> $list_ancestors */ |
|
91 | - $list_ancestors = $list_ancestors->mapWithKeys(function (stdClass $value) use ($tree): ?array { |
|
92 | - $indi = Registry::individualFactory()->make($value->majs_i_id, $tree); |
|
93 | - return ($indi !== null && $indi->canShowName()) ? [(int) $value->majs_sosa => $indi] : null; |
|
94 | - })->filter(); |
|
95 | - |
|
96 | - $nb_ancestors_shown = $list_ancestors->count(); |
|
97 | - |
|
98 | - return $this->viewResponse($this->module->name() . '::list-ancestors-indi-tab', [ |
|
99 | - 'module_name' => $this->module->name(), |
|
100 | - 'title' => I18N::translate('Sosa Ancestors'), |
|
101 | - 'tree' => $tree, |
|
102 | - 'list_ancestors' => $list_ancestors, |
|
103 | - 'nb_ancestors_all' => $nb_ancestors_all, |
|
104 | - 'nb_ancestors_theor' => pow(2, $current_gen - 1), |
|
105 | - 'nb_ancestors_shown' => $nb_ancestors_shown |
|
106 | - ]); |
|
107 | - } |
|
38 | + use ViewResponseTrait; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var SosaModule|null $module |
|
42 | + */ |
|
43 | + private $module; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var SosaRecordsService $sosa_record_service |
|
47 | + */ |
|
48 | + private $sosa_record_service; |
|
49 | + |
|
50 | + /** |
|
51 | + * Constructor for AncestorsListIndividual Request Handler |
|
52 | + * |
|
53 | + * @param ModuleService $module_service |
|
54 | + * @param SosaRecordsService $sosa_record_service |
|
55 | + */ |
|
56 | + public function __construct( |
|
57 | + ModuleService $module_service, |
|
58 | + SosaRecordsService $sosa_record_service |
|
59 | + ) { |
|
60 | + $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
61 | + $this->sosa_record_service = $sosa_record_service; |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * {@inheritDoc} |
|
66 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
67 | + */ |
|
68 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
69 | + { |
|
70 | + $this->layout = 'layouts/ajax'; |
|
71 | + |
|
72 | + if ($this->module === null) { |
|
73 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
74 | + } |
|
75 | + |
|
76 | + $tree = $request->getAttribute('tree'); |
|
77 | + assert($tree instanceof Tree); |
|
78 | + |
|
79 | + $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
|
80 | + |
|
81 | + $current_gen = (int) ($request->getAttribute('gen') ?? 0); |
|
82 | + |
|
83 | + if ($current_gen <= 0) { |
|
84 | + return response('Invalid generation', StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY); |
|
85 | + } |
|
86 | + |
|
87 | + $list_ancestors = $this->sosa_record_service->listAncestorsAtGeneration($tree, $user, $current_gen); |
|
88 | + $nb_ancestors_all = $list_ancestors->count(); |
|
89 | + |
|
90 | + /** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Individual> $list_ancestors */ |
|
91 | + $list_ancestors = $list_ancestors->mapWithKeys(function (stdClass $value) use ($tree): ?array { |
|
92 | + $indi = Registry::individualFactory()->make($value->majs_i_id, $tree); |
|
93 | + return ($indi !== null && $indi->canShowName()) ? [(int) $value->majs_sosa => $indi] : null; |
|
94 | + })->filter(); |
|
95 | + |
|
96 | + $nb_ancestors_shown = $list_ancestors->count(); |
|
97 | + |
|
98 | + return $this->viewResponse($this->module->name() . '::list-ancestors-indi-tab', [ |
|
99 | + 'module_name' => $this->module->name(), |
|
100 | + 'title' => I18N::translate('Sosa Ancestors'), |
|
101 | + 'tree' => $tree, |
|
102 | + 'list_ancestors' => $list_ancestors, |
|
103 | + 'nb_ancestors_all' => $nb_ancestors_all, |
|
104 | + 'nb_ancestors_theor' => pow(2, $current_gen - 1), |
|
105 | + 'nb_ancestors_shown' => $nb_ancestors_shown |
|
106 | + ]); |
|
107 | + } |
|
108 | 108 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
80 | 80 | |
81 | - $current_gen = (int) ($request->getAttribute('gen') ?? 0); |
|
81 | + $current_gen = (int)($request->getAttribute('gen') ?? 0); |
|
82 | 82 | |
83 | 83 | if ($current_gen <= 0) { |
84 | 84 | return response('Invalid generation', StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY); |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | $nb_ancestors_all = $list_ancestors->count(); |
89 | 89 | |
90 | 90 | /** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Individual> $list_ancestors */ |
91 | - $list_ancestors = $list_ancestors->mapWithKeys(function (stdClass $value) use ($tree): ?array { |
|
91 | + $list_ancestors = $list_ancestors->mapWithKeys(function(stdClass $value) use ($tree): ?array { |
|
92 | 92 | $indi = Registry::individualFactory()->make($value->majs_i_id, $tree); |
93 | - return ($indi !== null && $indi->canShowName()) ? [(int) $value->majs_sosa => $indi] : null; |
|
93 | + return ($indi !== null && $indi->canShowName()) ? [(int)$value->majs_sosa => $indi] : null; |
|
94 | 94 | })->filter(); |
95 | 95 | |
96 | 96 | $nb_ancestors_shown = $list_ancestors->count(); |
97 | 97 | |
98 | - return $this->viewResponse($this->module->name() . '::list-ancestors-indi-tab', [ |
|
98 | + return $this->viewResponse($this->module->name().'::list-ancestors-indi-tab', [ |
|
99 | 99 | 'module_name' => $this->module->name(), |
100 | 100 | 'title' => I18N::translate('Sosa Ancestors'), |
101 | 101 | 'tree' => $tree, |
@@ -36,88 +36,88 @@ |
||
36 | 36 | */ |
37 | 37 | class MissingAncestorsList implements RequestHandlerInterface |
38 | 38 | { |
39 | - use ViewResponseTrait; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var SosaModule|null $module |
|
43 | - */ |
|
44 | - private $module; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var SosaRecordsService $sosa_record_service |
|
48 | - */ |
|
49 | - private $sosa_record_service; |
|
50 | - |
|
51 | - /** |
|
52 | - * Constructor for MissingAncestorsList Request Handler |
|
53 | - * |
|
54 | - * @param ModuleService $module_service |
|
55 | - * @param SosaRecordsService $sosa_record_service |
|
56 | - */ |
|
57 | - public function __construct( |
|
58 | - ModuleService $module_service, |
|
59 | - SosaRecordsService $sosa_record_service |
|
60 | - ) { |
|
61 | - $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
62 | - $this->sosa_record_service = $sosa_record_service; |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * {@inheritDoc} |
|
67 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
68 | - */ |
|
69 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
70 | - { |
|
71 | - if ($this->module === null) { |
|
72 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
73 | - } |
|
74 | - |
|
75 | - $tree = $request->getAttribute('tree'); |
|
76 | - assert($tree instanceof Tree); |
|
77 | - |
|
78 | - $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
|
79 | - |
|
80 | - /** @var SosaStatisticsService $sosa_stats_service */ |
|
81 | - $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
|
82 | - |
|
83 | - $current_gen = (int) ($request->getQueryParams()['gen'] ?? $request->getAttribute('gen') ?? 0); |
|
84 | - |
|
85 | - $list_missing = $this->sosa_record_service->listMissingAncestorsAtGeneration($tree, $user, $current_gen); |
|
86 | - $nb_missing_diff = $list_missing->sum(function (stdClass $value): int { |
|
87 | - return ($value->majs_fat_id === null ? 1 : 0) + ($value->majs_mot_id === null ? 1 : 0); |
|
88 | - }); |
|
89 | - |
|
90 | - $list_missing = $list_missing->map(function (stdClass $value) use ($tree): ?MissingAncestor { |
|
91 | - $indi = Registry::individualFactory()->make($value->majs_i_id, $tree); |
|
92 | - if ($indi !== null && $indi->canShowName()) { |
|
93 | - return new MissingAncestor( |
|
94 | - $indi, |
|
95 | - (int) $value->majs_sosa, |
|
96 | - $value->majs_fat_id === null, |
|
97 | - $value->majs_mot_id === null |
|
98 | - ); |
|
99 | - } |
|
100 | - return null; |
|
101 | - })->filter(); |
|
102 | - |
|
103 | - $nb_missing_shown = $list_missing->sum(function (MissingAncestor $value): int { |
|
104 | - return ($value->isFatherMissing() ? 1 : 0) + ($value->isMotherMissing() ? 1 : 0); |
|
105 | - }); |
|
106 | - |
|
107 | - return $this->viewResponse($this->module->name() . '::list-missing-page', [ |
|
108 | - 'module_name' => $this->module->name(), |
|
109 | - 'title' => I18N::translate('Missing Ancestors'), |
|
110 | - 'tree' => $tree, |
|
111 | - 'root_indi' => $sosa_stats_service->rootIndividual(), |
|
112 | - 'max_gen' => $sosa_stats_service->maxGeneration(), |
|
113 | - 'current_gen' => $current_gen, |
|
114 | - 'list_missing' => $list_missing, |
|
115 | - 'nb_missing_diff' => $nb_missing_diff, |
|
116 | - 'nb_missing_shown' => $nb_missing_shown, |
|
117 | - 'gen_completeness' => |
|
118 | - $sosa_stats_service->totalAncestorsAtGeneration($current_gen) / pow(2, $current_gen - 1), |
|
119 | - 'gen_potential' => |
|
120 | - $sosa_stats_service->totalAncestorsAtGeneration($current_gen - 1) / pow(2, $current_gen - 2) |
|
121 | - ]); |
|
122 | - } |
|
39 | + use ViewResponseTrait; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var SosaModule|null $module |
|
43 | + */ |
|
44 | + private $module; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var SosaRecordsService $sosa_record_service |
|
48 | + */ |
|
49 | + private $sosa_record_service; |
|
50 | + |
|
51 | + /** |
|
52 | + * Constructor for MissingAncestorsList Request Handler |
|
53 | + * |
|
54 | + * @param ModuleService $module_service |
|
55 | + * @param SosaRecordsService $sosa_record_service |
|
56 | + */ |
|
57 | + public function __construct( |
|
58 | + ModuleService $module_service, |
|
59 | + SosaRecordsService $sosa_record_service |
|
60 | + ) { |
|
61 | + $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
62 | + $this->sosa_record_service = $sosa_record_service; |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * {@inheritDoc} |
|
67 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
68 | + */ |
|
69 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
70 | + { |
|
71 | + if ($this->module === null) { |
|
72 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
73 | + } |
|
74 | + |
|
75 | + $tree = $request->getAttribute('tree'); |
|
76 | + assert($tree instanceof Tree); |
|
77 | + |
|
78 | + $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
|
79 | + |
|
80 | + /** @var SosaStatisticsService $sosa_stats_service */ |
|
81 | + $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
|
82 | + |
|
83 | + $current_gen = (int) ($request->getQueryParams()['gen'] ?? $request->getAttribute('gen') ?? 0); |
|
84 | + |
|
85 | + $list_missing = $this->sosa_record_service->listMissingAncestorsAtGeneration($tree, $user, $current_gen); |
|
86 | + $nb_missing_diff = $list_missing->sum(function (stdClass $value): int { |
|
87 | + return ($value->majs_fat_id === null ? 1 : 0) + ($value->majs_mot_id === null ? 1 : 0); |
|
88 | + }); |
|
89 | + |
|
90 | + $list_missing = $list_missing->map(function (stdClass $value) use ($tree): ?MissingAncestor { |
|
91 | + $indi = Registry::individualFactory()->make($value->majs_i_id, $tree); |
|
92 | + if ($indi !== null && $indi->canShowName()) { |
|
93 | + return new MissingAncestor( |
|
94 | + $indi, |
|
95 | + (int) $value->majs_sosa, |
|
96 | + $value->majs_fat_id === null, |
|
97 | + $value->majs_mot_id === null |
|
98 | + ); |
|
99 | + } |
|
100 | + return null; |
|
101 | + })->filter(); |
|
102 | + |
|
103 | + $nb_missing_shown = $list_missing->sum(function (MissingAncestor $value): int { |
|
104 | + return ($value->isFatherMissing() ? 1 : 0) + ($value->isMotherMissing() ? 1 : 0); |
|
105 | + }); |
|
106 | + |
|
107 | + return $this->viewResponse($this->module->name() . '::list-missing-page', [ |
|
108 | + 'module_name' => $this->module->name(), |
|
109 | + 'title' => I18N::translate('Missing Ancestors'), |
|
110 | + 'tree' => $tree, |
|
111 | + 'root_indi' => $sosa_stats_service->rootIndividual(), |
|
112 | + 'max_gen' => $sosa_stats_service->maxGeneration(), |
|
113 | + 'current_gen' => $current_gen, |
|
114 | + 'list_missing' => $list_missing, |
|
115 | + 'nb_missing_diff' => $nb_missing_diff, |
|
116 | + 'nb_missing_shown' => $nb_missing_shown, |
|
117 | + 'gen_completeness' => |
|
118 | + $sosa_stats_service->totalAncestorsAtGeneration($current_gen) / pow(2, $current_gen - 1), |
|
119 | + 'gen_potential' => |
|
120 | + $sosa_stats_service->totalAncestorsAtGeneration($current_gen - 1) / pow(2, $current_gen - 2) |
|
121 | + ]); |
|
122 | + } |
|
123 | 123 | } |
@@ -80,19 +80,19 @@ discard block |
||
80 | 80 | /** @var SosaStatisticsService $sosa_stats_service */ |
81 | 81 | $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
82 | 82 | |
83 | - $current_gen = (int) ($request->getQueryParams()['gen'] ?? $request->getAttribute('gen') ?? 0); |
|
83 | + $current_gen = (int)($request->getQueryParams()['gen'] ?? $request->getAttribute('gen') ?? 0); |
|
84 | 84 | |
85 | 85 | $list_missing = $this->sosa_record_service->listMissingAncestorsAtGeneration($tree, $user, $current_gen); |
86 | - $nb_missing_diff = $list_missing->sum(function (stdClass $value): int { |
|
86 | + $nb_missing_diff = $list_missing->sum(function(stdClass $value): int { |
|
87 | 87 | return ($value->majs_fat_id === null ? 1 : 0) + ($value->majs_mot_id === null ? 1 : 0); |
88 | 88 | }); |
89 | 89 | |
90 | - $list_missing = $list_missing->map(function (stdClass $value) use ($tree): ?MissingAncestor { |
|
90 | + $list_missing = $list_missing->map(function(stdClass $value) use ($tree): ?MissingAncestor { |
|
91 | 91 | $indi = Registry::individualFactory()->make($value->majs_i_id, $tree); |
92 | 92 | if ($indi !== null && $indi->canShowName()) { |
93 | 93 | return new MissingAncestor( |
94 | 94 | $indi, |
95 | - (int) $value->majs_sosa, |
|
95 | + (int)$value->majs_sosa, |
|
96 | 96 | $value->majs_fat_id === null, |
97 | 97 | $value->majs_mot_id === null |
98 | 98 | ); |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | return null; |
101 | 101 | })->filter(); |
102 | 102 | |
103 | - $nb_missing_shown = $list_missing->sum(function (MissingAncestor $value): int { |
|
103 | + $nb_missing_shown = $list_missing->sum(function(MissingAncestor $value): int { |
|
104 | 104 | return ($value->isFatherMissing() ? 1 : 0) + ($value->isMotherMissing() ? 1 : 0); |
105 | 105 | }); |
106 | 106 | |
107 | - return $this->viewResponse($this->module->name() . '::list-missing-page', [ |
|
107 | + return $this->viewResponse($this->module->name().'::list-missing-page', [ |
|
108 | 108 | 'module_name' => $this->module->name(), |
109 | 109 | 'title' => I18N::translate('Missing Ancestors'), |
110 | 110 | 'tree' => $tree, |
@@ -35,73 +35,73 @@ |
||
35 | 35 | */ |
36 | 36 | class AncestorsListFamily implements RequestHandlerInterface |
37 | 37 | { |
38 | - use ViewResponseTrait; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var SosaModule|null $module |
|
42 | - */ |
|
43 | - private $module; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var SosaRecordsService $sosa_record_service |
|
47 | - */ |
|
48 | - private $sosa_record_service; |
|
49 | - |
|
50 | - /** |
|
51 | - * Constructor for AncestorsListFamily Request Handler |
|
52 | - * |
|
53 | - * @param ModuleService $module_service |
|
54 | - * @param SosaRecordsService $sosa_record_service |
|
55 | - */ |
|
56 | - public function __construct( |
|
57 | - ModuleService $module_service, |
|
58 | - SosaRecordsService $sosa_record_service |
|
59 | - ) { |
|
60 | - $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
61 | - $this->sosa_record_service = $sosa_record_service; |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * {@inheritDoc} |
|
66 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
67 | - */ |
|
68 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
69 | - { |
|
70 | - $this->layout = 'layouts/ajax'; |
|
71 | - |
|
72 | - if ($this->module === null) { |
|
73 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
74 | - } |
|
75 | - |
|
76 | - $tree = $request->getAttribute('tree'); |
|
77 | - assert($tree instanceof Tree); |
|
78 | - |
|
79 | - $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
|
80 | - |
|
81 | - $current_gen = (int) ($request->getAttribute('gen') ?? 0); |
|
82 | - |
|
83 | - if ($current_gen <= 0) { |
|
84 | - return response('Invalid generation', StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY); |
|
85 | - } |
|
86 | - |
|
87 | - $list_families = $this->sosa_record_service->listAncestorFamiliesAtGeneration($tree, $user, $current_gen); |
|
88 | - $nb_families_all = $list_families->count(); |
|
89 | - |
|
90 | - /** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Family> $list_families */ |
|
91 | - $list_families = $list_families->mapWithKeys(function (stdClass $value) use ($tree): ?array { |
|
92 | - $fam = Registry::familyFactory()->make($value->f_id, $tree); |
|
93 | - return ($fam !== null && $fam->canShow()) ? [(int) $value->majs_sosa => $fam] : null; |
|
94 | - })->filter(); |
|
95 | - |
|
96 | - $nb_families_shown = $list_families->count(); |
|
97 | - |
|
98 | - return $this->viewResponse($this->module->name() . '::list-ancestors-fam-tab', [ |
|
99 | - 'module_name' => $this->module->name(), |
|
100 | - 'title' => I18N::translate('Sosa Ancestors'), |
|
101 | - 'tree' => $tree, |
|
102 | - 'list_families' => $list_families, |
|
103 | - 'nb_families_all' => $nb_families_all, |
|
104 | - 'nb_families_shown' => $nb_families_shown |
|
105 | - ]); |
|
106 | - } |
|
38 | + use ViewResponseTrait; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var SosaModule|null $module |
|
42 | + */ |
|
43 | + private $module; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var SosaRecordsService $sosa_record_service |
|
47 | + */ |
|
48 | + private $sosa_record_service; |
|
49 | + |
|
50 | + /** |
|
51 | + * Constructor for AncestorsListFamily Request Handler |
|
52 | + * |
|
53 | + * @param ModuleService $module_service |
|
54 | + * @param SosaRecordsService $sosa_record_service |
|
55 | + */ |
|
56 | + public function __construct( |
|
57 | + ModuleService $module_service, |
|
58 | + SosaRecordsService $sosa_record_service |
|
59 | + ) { |
|
60 | + $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
61 | + $this->sosa_record_service = $sosa_record_service; |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * {@inheritDoc} |
|
66 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
67 | + */ |
|
68 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
69 | + { |
|
70 | + $this->layout = 'layouts/ajax'; |
|
71 | + |
|
72 | + if ($this->module === null) { |
|
73 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
74 | + } |
|
75 | + |
|
76 | + $tree = $request->getAttribute('tree'); |
|
77 | + assert($tree instanceof Tree); |
|
78 | + |
|
79 | + $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
|
80 | + |
|
81 | + $current_gen = (int) ($request->getAttribute('gen') ?? 0); |
|
82 | + |
|
83 | + if ($current_gen <= 0) { |
|
84 | + return response('Invalid generation', StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY); |
|
85 | + } |
|
86 | + |
|
87 | + $list_families = $this->sosa_record_service->listAncestorFamiliesAtGeneration($tree, $user, $current_gen); |
|
88 | + $nb_families_all = $list_families->count(); |
|
89 | + |
|
90 | + /** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Family> $list_families */ |
|
91 | + $list_families = $list_families->mapWithKeys(function (stdClass $value) use ($tree): ?array { |
|
92 | + $fam = Registry::familyFactory()->make($value->f_id, $tree); |
|
93 | + return ($fam !== null && $fam->canShow()) ? [(int) $value->majs_sosa => $fam] : null; |
|
94 | + })->filter(); |
|
95 | + |
|
96 | + $nb_families_shown = $list_families->count(); |
|
97 | + |
|
98 | + return $this->viewResponse($this->module->name() . '::list-ancestors-fam-tab', [ |
|
99 | + 'module_name' => $this->module->name(), |
|
100 | + 'title' => I18N::translate('Sosa Ancestors'), |
|
101 | + 'tree' => $tree, |
|
102 | + 'list_families' => $list_families, |
|
103 | + 'nb_families_all' => $nb_families_all, |
|
104 | + 'nb_families_shown' => $nb_families_shown |
|
105 | + ]); |
|
106 | + } |
|
107 | 107 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
80 | 80 | |
81 | - $current_gen = (int) ($request->getAttribute('gen') ?? 0); |
|
81 | + $current_gen = (int)($request->getAttribute('gen') ?? 0); |
|
82 | 82 | |
83 | 83 | if ($current_gen <= 0) { |
84 | 84 | return response('Invalid generation', StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY); |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | $nb_families_all = $list_families->count(); |
89 | 89 | |
90 | 90 | /** @var \Illuminate\Support\Collection<int, \Fisharebest\Webtrees\Family> $list_families */ |
91 | - $list_families = $list_families->mapWithKeys(function (stdClass $value) use ($tree): ?array { |
|
91 | + $list_families = $list_families->mapWithKeys(function(stdClass $value) use ($tree): ?array { |
|
92 | 92 | $fam = Registry::familyFactory()->make($value->f_id, $tree); |
93 | - return ($fam !== null && $fam->canShow()) ? [(int) $value->majs_sosa => $fam] : null; |
|
93 | + return ($fam !== null && $fam->canShow()) ? [(int)$value->majs_sosa => $fam] : null; |
|
94 | 94 | })->filter(); |
95 | 95 | |
96 | 96 | $nb_families_shown = $list_families->count(); |
97 | 97 | |
98 | - return $this->viewResponse($this->module->name() . '::list-ancestors-fam-tab', [ |
|
98 | + return $this->viewResponse($this->module->name().'::list-ancestors-fam-tab', [ |
|
99 | 99 | 'module_name' => $this->module->name(), |
100 | 100 | 'title' => I18N::translate('Sosa Ancestors'), |
101 | 101 | 'tree' => $tree, |
@@ -33,59 +33,59 @@ |
||
33 | 33 | */ |
34 | 34 | class AncestorsList implements RequestHandlerInterface |
35 | 35 | { |
36 | - use ViewResponseTrait; |
|
36 | + use ViewResponseTrait; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @var SosaModule|null $module |
|
40 | - */ |
|
41 | - private $module; |
|
38 | + /** |
|
39 | + * @var SosaModule|null $module |
|
40 | + */ |
|
41 | + private $module; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @var SosaRecordsService $sosa_record_service |
|
45 | - */ |
|
46 | - private $sosa_record_service; |
|
43 | + /** |
|
44 | + * @var SosaRecordsService $sosa_record_service |
|
45 | + */ |
|
46 | + private $sosa_record_service; |
|
47 | 47 | |
48 | - /** |
|
49 | - * Constructor for AncestorsList Request Handler |
|
50 | - * |
|
51 | - * @param ModuleService $module_service |
|
52 | - * @param SosaRecordsService $sosa_record_service |
|
53 | - */ |
|
54 | - public function __construct( |
|
55 | - ModuleService $module_service, |
|
56 | - SosaRecordsService $sosa_record_service |
|
57 | - ) { |
|
58 | - $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
59 | - $this->sosa_record_service = $sosa_record_service; |
|
60 | - } |
|
48 | + /** |
|
49 | + * Constructor for AncestorsList Request Handler |
|
50 | + * |
|
51 | + * @param ModuleService $module_service |
|
52 | + * @param SosaRecordsService $sosa_record_service |
|
53 | + */ |
|
54 | + public function __construct( |
|
55 | + ModuleService $module_service, |
|
56 | + SosaRecordsService $sosa_record_service |
|
57 | + ) { |
|
58 | + $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
59 | + $this->sosa_record_service = $sosa_record_service; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * {@inheritDoc} |
|
64 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
65 | - */ |
|
66 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
67 | - { |
|
68 | - if ($this->module === null) { |
|
69 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
70 | - } |
|
62 | + /** |
|
63 | + * {@inheritDoc} |
|
64 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
65 | + */ |
|
66 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
67 | + { |
|
68 | + if ($this->module === null) { |
|
69 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
70 | + } |
|
71 | 71 | |
72 | - $tree = $request->getAttribute('tree'); |
|
73 | - assert($tree instanceof Tree); |
|
72 | + $tree = $request->getAttribute('tree'); |
|
73 | + assert($tree instanceof Tree); |
|
74 | 74 | |
75 | - $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
|
75 | + $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
|
76 | 76 | |
77 | - /** @var SosaStatisticsService $sosa_stats_service */ |
|
78 | - $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
|
77 | + /** @var SosaStatisticsService $sosa_stats_service */ |
|
78 | + $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
|
79 | 79 | |
80 | - $current_gen = (int) ($request->getQueryParams()['gen'] ?? $request->getAttribute('gen') ?? 0); |
|
80 | + $current_gen = (int) ($request->getQueryParams()['gen'] ?? $request->getAttribute('gen') ?? 0); |
|
81 | 81 | |
82 | - return $this->viewResponse($this->module->name() . '::list-ancestors-page', [ |
|
83 | - 'module_name' => $this->module->name(), |
|
84 | - 'title' => I18N::translate('Sosa Ancestors'), |
|
85 | - 'tree' => $tree, |
|
86 | - 'root_indi' => $sosa_stats_service->rootIndividual(), |
|
87 | - 'max_gen' => $sosa_stats_service->maxGeneration(), |
|
88 | - 'current_gen' => $current_gen |
|
89 | - ]); |
|
90 | - } |
|
82 | + return $this->viewResponse($this->module->name() . '::list-ancestors-page', [ |
|
83 | + 'module_name' => $this->module->name(), |
|
84 | + 'title' => I18N::translate('Sosa Ancestors'), |
|
85 | + 'tree' => $tree, |
|
86 | + 'root_indi' => $sosa_stats_service->rootIndividual(), |
|
87 | + 'max_gen' => $sosa_stats_service->maxGeneration(), |
|
88 | + 'current_gen' => $current_gen |
|
89 | + ]); |
|
90 | + } |
|
91 | 91 | } |
@@ -77,9 +77,9 @@ |
||
77 | 77 | /** @var SosaStatisticsService $sosa_stats_service */ |
78 | 78 | $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
79 | 79 | |
80 | - $current_gen = (int) ($request->getQueryParams()['gen'] ?? $request->getAttribute('gen') ?? 0); |
|
80 | + $current_gen = (int)($request->getQueryParams()['gen'] ?? $request->getAttribute('gen') ?? 0); |
|
81 | 81 | |
82 | - return $this->viewResponse($this->module->name() . '::list-ancestors-page', [ |
|
82 | + return $this->viewResponse($this->module->name().'::list-ancestors-page', [ |
|
83 | 83 | 'module_name' => $this->module->name(), |
84 | 84 | 'title' => I18N::translate('Sosa Ancestors'), |
85 | 85 | 'tree' => $tree, |
@@ -36,144 +36,144 @@ |
||
36 | 36 | */ |
37 | 37 | class SosaStatistics implements RequestHandlerInterface |
38 | 38 | { |
39 | - use ViewResponseTrait; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var SosaModule|null $module |
|
43 | - */ |
|
44 | - private $module; |
|
45 | - |
|
46 | - /** |
|
47 | - * Constructor for AncestorsList Request Handler |
|
48 | - * |
|
49 | - * @param ModuleService $module_service |
|
50 | - */ |
|
51 | - public function __construct(ModuleService $module_service) |
|
52 | - { |
|
53 | - $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * {@inheritDoc} |
|
58 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
59 | - */ |
|
60 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
61 | - { |
|
62 | - if ($this->module === null) { |
|
63 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
64 | - } |
|
65 | - |
|
66 | - $tree = $request->getAttribute('tree'); |
|
67 | - assert($tree instanceof Tree); |
|
68 | - |
|
69 | - $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
|
70 | - |
|
71 | - /** @var SosaStatisticsService $sosa_stats_service */ |
|
72 | - $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
|
73 | - |
|
74 | - return $this->viewResponse($this->module->name() . '::statistics-page', [ |
|
75 | - 'module_name' => $this->module->name(), |
|
76 | - 'title' => I18N::translate('Sosa Statistics'), |
|
77 | - 'tree' => $tree, |
|
78 | - 'theme' => app(ModuleThemeInterface::class), |
|
79 | - 'root_indi' => $sosa_stats_service->rootIndividual(), |
|
80 | - 'general_stats' => $this->statisticsGeneral($sosa_stats_service), |
|
81 | - 'generation_stats' => $this->statisticsByGenerations($sosa_stats_service), |
|
82 | - 'generation_depth' => $sosa_stats_service->generationDepthStatsAtGeneration(1)->first(), |
|
83 | - 'multiple_sosas' => $sosa_stats_service->topMultipleAncestorsWithNoTies(10)->groupBy('sosa_count'), |
|
84 | - 'sosa_dispersion_g2' => $sosa_stats_service->ancestorsDispersionForGeneration(2), |
|
85 | - 'sosa_dispersion_g3' => $sosa_stats_service->ancestorsDispersionForGeneration(3), |
|
86 | - 'gen_depth_g3' => $sosa_stats_service->generationDepthStatsAtGeneration(3) |
|
87 | - ]); |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Retrieve and compute the global statistics of ancestors for the tree. |
|
92 | - * Statistics include the number of ancestors, the number of different ancestors, pedigree collapse... |
|
93 | - * |
|
94 | - * @param SosaStatisticsService $sosa_stats_service |
|
95 | - * @return array<string, int|float> |
|
96 | - */ |
|
97 | - private function statisticsGeneral(SosaStatisticsService $sosa_stats_service): array |
|
98 | - { |
|
99 | - $ancestors_count = $sosa_stats_service->totalAncestors(); |
|
100 | - $ancestors_distinct_count = $sosa_stats_service->totalDistinctAncestors(); |
|
101 | - $individual_count = $sosa_stats_service->totalIndividuals(); |
|
102 | - |
|
103 | - return [ |
|
104 | - 'sosa_count' => $ancestors_count, |
|
105 | - 'distinct_count' => $ancestors_distinct_count, |
|
106 | - 'sosa_rate' => $this->safeDivision( |
|
107 | - BigInteger::of($ancestors_distinct_count), |
|
108 | - BigInteger::of($individual_count) |
|
109 | - ), |
|
110 | - 'mean_gen_time' => $sosa_stats_service->meanGenerationTime() |
|
111 | - ]; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Retrieve and compute the statistics of ancestors by generations. |
|
116 | - * Statistics include the number of ancestors, the number of different ancestors, cumulative statistics... |
|
117 | - * |
|
118 | - * @param SosaStatisticsService $sosa_stats_service |
|
119 | - * @return array<int, array<string, int|float>> |
|
120 | - */ |
|
121 | - private function statisticsByGenerations(SosaStatisticsService $sosa_stats_service): array |
|
122 | - { |
|
123 | - $stats_by_gen = $sosa_stats_service->statisticsByGenerations(); |
|
124 | - |
|
125 | - $generation_stats = array(); |
|
126 | - |
|
127 | - foreach ($stats_by_gen as $gen => $stats_gen) { |
|
128 | - $gen_diff = $gen > 1 ? |
|
129 | - (int) $stats_gen['diffSosaTotalCount'] - (int) $stats_by_gen[$gen - 1]['diffSosaTotalCount'] : |
|
130 | - 1; |
|
131 | - $generation_stats[$gen] = array( |
|
132 | - 'gen_min_birth' => $stats_gen['firstBirth'] ?? (int) $stats_gen['firstEstimatedBirth'], |
|
133 | - 'gen_max_birth' => $stats_gen['lastBirth'] ?? (int) $stats_gen['lastEstimatedBirth'], |
|
134 | - 'theoretical' => BigInteger::of(2)->power($gen - 1)->toInt(), |
|
135 | - 'known' => (int) $stats_gen['sosaCount'], |
|
136 | - 'perc_known' => $this->safeDivision( |
|
137 | - BigInteger::of((int) $stats_gen['sosaCount']), |
|
138 | - BigInteger::of(2)->power($gen - 1) |
|
139 | - ), |
|
140 | - 'missing' => $gen > 1 ? |
|
141 | - 2 * (int) $stats_by_gen[$gen - 1]['sosaCount'] - (int) $stats_gen['sosaCount'] : |
|
142 | - 0, |
|
143 | - 'perc_missing' => $gen > 1 ? |
|
144 | - 1 - $this->safeDivision( |
|
145 | - BigInteger::of((int) $stats_gen['sosaCount']), |
|
146 | - BigInteger::of(2 * (int) $stats_by_gen[$gen - 1]['sosaCount']) |
|
147 | - ) : |
|
148 | - 0, |
|
149 | - 'total_known' => (int) $stats_gen['sosaTotalCount'], |
|
150 | - 'perc_total_known' => $this->safeDivision( |
|
151 | - BigInteger::of((int) $stats_gen['sosaTotalCount']), |
|
152 | - BigInteger::of(2)->power($gen)->minus(1) |
|
153 | - ), |
|
154 | - 'different' => $gen_diff, |
|
155 | - 'perc_different' => $this->safeDivision( |
|
156 | - BigInteger::of($gen_diff), |
|
157 | - BigInteger::of((int) $stats_gen['sosaCount']) |
|
158 | - ), |
|
159 | - 'total_different' => (int) $stats_gen['diffSosaTotalCount'] |
|
160 | - ); |
|
161 | - } |
|
162 | - |
|
163 | - return $generation_stats; |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * Return the result of a division, and a default value if denominator is 0 |
|
168 | - * |
|
169 | - * @param BigInteger $p Numerator |
|
170 | - * @param BigInteger $q Denominator |
|
171 | - * @param int $scale Rounding scale |
|
172 | - * @param float $default Value if denominator is 0 |
|
173 | - * @return float |
|
174 | - */ |
|
175 | - private function safeDivision(BigInteger $p, BigInteger $q, int $scale = 10, float $default = 0): float |
|
176 | - { |
|
177 | - return $q->isZero() ? $default : $p->toBigDecimal()->dividedBy($q, $scale, RoundingMode::HALF_DOWN)->toFloat(); |
|
178 | - } |
|
39 | + use ViewResponseTrait; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var SosaModule|null $module |
|
43 | + */ |
|
44 | + private $module; |
|
45 | + |
|
46 | + /** |
|
47 | + * Constructor for AncestorsList Request Handler |
|
48 | + * |
|
49 | + * @param ModuleService $module_service |
|
50 | + */ |
|
51 | + public function __construct(ModuleService $module_service) |
|
52 | + { |
|
53 | + $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * {@inheritDoc} |
|
58 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
59 | + */ |
|
60 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
61 | + { |
|
62 | + if ($this->module === null) { |
|
63 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
64 | + } |
|
65 | + |
|
66 | + $tree = $request->getAttribute('tree'); |
|
67 | + assert($tree instanceof Tree); |
|
68 | + |
|
69 | + $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
|
70 | + |
|
71 | + /** @var SosaStatisticsService $sosa_stats_service */ |
|
72 | + $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
|
73 | + |
|
74 | + return $this->viewResponse($this->module->name() . '::statistics-page', [ |
|
75 | + 'module_name' => $this->module->name(), |
|
76 | + 'title' => I18N::translate('Sosa Statistics'), |
|
77 | + 'tree' => $tree, |
|
78 | + 'theme' => app(ModuleThemeInterface::class), |
|
79 | + 'root_indi' => $sosa_stats_service->rootIndividual(), |
|
80 | + 'general_stats' => $this->statisticsGeneral($sosa_stats_service), |
|
81 | + 'generation_stats' => $this->statisticsByGenerations($sosa_stats_service), |
|
82 | + 'generation_depth' => $sosa_stats_service->generationDepthStatsAtGeneration(1)->first(), |
|
83 | + 'multiple_sosas' => $sosa_stats_service->topMultipleAncestorsWithNoTies(10)->groupBy('sosa_count'), |
|
84 | + 'sosa_dispersion_g2' => $sosa_stats_service->ancestorsDispersionForGeneration(2), |
|
85 | + 'sosa_dispersion_g3' => $sosa_stats_service->ancestorsDispersionForGeneration(3), |
|
86 | + 'gen_depth_g3' => $sosa_stats_service->generationDepthStatsAtGeneration(3) |
|
87 | + ]); |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Retrieve and compute the global statistics of ancestors for the tree. |
|
92 | + * Statistics include the number of ancestors, the number of different ancestors, pedigree collapse... |
|
93 | + * |
|
94 | + * @param SosaStatisticsService $sosa_stats_service |
|
95 | + * @return array<string, int|float> |
|
96 | + */ |
|
97 | + private function statisticsGeneral(SosaStatisticsService $sosa_stats_service): array |
|
98 | + { |
|
99 | + $ancestors_count = $sosa_stats_service->totalAncestors(); |
|
100 | + $ancestors_distinct_count = $sosa_stats_service->totalDistinctAncestors(); |
|
101 | + $individual_count = $sosa_stats_service->totalIndividuals(); |
|
102 | + |
|
103 | + return [ |
|
104 | + 'sosa_count' => $ancestors_count, |
|
105 | + 'distinct_count' => $ancestors_distinct_count, |
|
106 | + 'sosa_rate' => $this->safeDivision( |
|
107 | + BigInteger::of($ancestors_distinct_count), |
|
108 | + BigInteger::of($individual_count) |
|
109 | + ), |
|
110 | + 'mean_gen_time' => $sosa_stats_service->meanGenerationTime() |
|
111 | + ]; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Retrieve and compute the statistics of ancestors by generations. |
|
116 | + * Statistics include the number of ancestors, the number of different ancestors, cumulative statistics... |
|
117 | + * |
|
118 | + * @param SosaStatisticsService $sosa_stats_service |
|
119 | + * @return array<int, array<string, int|float>> |
|
120 | + */ |
|
121 | + private function statisticsByGenerations(SosaStatisticsService $sosa_stats_service): array |
|
122 | + { |
|
123 | + $stats_by_gen = $sosa_stats_service->statisticsByGenerations(); |
|
124 | + |
|
125 | + $generation_stats = array(); |
|
126 | + |
|
127 | + foreach ($stats_by_gen as $gen => $stats_gen) { |
|
128 | + $gen_diff = $gen > 1 ? |
|
129 | + (int) $stats_gen['diffSosaTotalCount'] - (int) $stats_by_gen[$gen - 1]['diffSosaTotalCount'] : |
|
130 | + 1; |
|
131 | + $generation_stats[$gen] = array( |
|
132 | + 'gen_min_birth' => $stats_gen['firstBirth'] ?? (int) $stats_gen['firstEstimatedBirth'], |
|
133 | + 'gen_max_birth' => $stats_gen['lastBirth'] ?? (int) $stats_gen['lastEstimatedBirth'], |
|
134 | + 'theoretical' => BigInteger::of(2)->power($gen - 1)->toInt(), |
|
135 | + 'known' => (int) $stats_gen['sosaCount'], |
|
136 | + 'perc_known' => $this->safeDivision( |
|
137 | + BigInteger::of((int) $stats_gen['sosaCount']), |
|
138 | + BigInteger::of(2)->power($gen - 1) |
|
139 | + ), |
|
140 | + 'missing' => $gen > 1 ? |
|
141 | + 2 * (int) $stats_by_gen[$gen - 1]['sosaCount'] - (int) $stats_gen['sosaCount'] : |
|
142 | + 0, |
|
143 | + 'perc_missing' => $gen > 1 ? |
|
144 | + 1 - $this->safeDivision( |
|
145 | + BigInteger::of((int) $stats_gen['sosaCount']), |
|
146 | + BigInteger::of(2 * (int) $stats_by_gen[$gen - 1]['sosaCount']) |
|
147 | + ) : |
|
148 | + 0, |
|
149 | + 'total_known' => (int) $stats_gen['sosaTotalCount'], |
|
150 | + 'perc_total_known' => $this->safeDivision( |
|
151 | + BigInteger::of((int) $stats_gen['sosaTotalCount']), |
|
152 | + BigInteger::of(2)->power($gen)->minus(1) |
|
153 | + ), |
|
154 | + 'different' => $gen_diff, |
|
155 | + 'perc_different' => $this->safeDivision( |
|
156 | + BigInteger::of($gen_diff), |
|
157 | + BigInteger::of((int) $stats_gen['sosaCount']) |
|
158 | + ), |
|
159 | + 'total_different' => (int) $stats_gen['diffSosaTotalCount'] |
|
160 | + ); |
|
161 | + } |
|
162 | + |
|
163 | + return $generation_stats; |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * Return the result of a division, and a default value if denominator is 0 |
|
168 | + * |
|
169 | + * @param BigInteger $p Numerator |
|
170 | + * @param BigInteger $q Denominator |
|
171 | + * @param int $scale Rounding scale |
|
172 | + * @param float $default Value if denominator is 0 |
|
173 | + * @return float |
|
174 | + */ |
|
175 | + private function safeDivision(BigInteger $p, BigInteger $q, int $scale = 10, float $default = 0): float |
|
176 | + { |
|
177 | + return $q->isZero() ? $default : $p->toBigDecimal()->dividedBy($q, $scale, RoundingMode::HALF_DOWN)->toFloat(); |
|
178 | + } |
|
179 | 179 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | /** @var SosaStatisticsService $sosa_stats_service */ |
72 | 72 | $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
73 | 73 | |
74 | - return $this->viewResponse($this->module->name() . '::statistics-page', [ |
|
74 | + return $this->viewResponse($this->module->name().'::statistics-page', [ |
|
75 | 75 | 'module_name' => $this->module->name(), |
76 | 76 | 'title' => I18N::translate('Sosa Statistics'), |
77 | 77 | 'tree' => $tree, |
@@ -126,37 +126,34 @@ discard block |
||
126 | 126 | |
127 | 127 | foreach ($stats_by_gen as $gen => $stats_gen) { |
128 | 128 | $gen_diff = $gen > 1 ? |
129 | - (int) $stats_gen['diffSosaTotalCount'] - (int) $stats_by_gen[$gen - 1]['diffSosaTotalCount'] : |
|
130 | - 1; |
|
129 | + (int)$stats_gen['diffSosaTotalCount'] - (int)$stats_by_gen[$gen - 1]['diffSosaTotalCount'] : 1; |
|
131 | 130 | $generation_stats[$gen] = array( |
132 | - 'gen_min_birth' => $stats_gen['firstBirth'] ?? (int) $stats_gen['firstEstimatedBirth'], |
|
133 | - 'gen_max_birth' => $stats_gen['lastBirth'] ?? (int) $stats_gen['lastEstimatedBirth'], |
|
131 | + 'gen_min_birth' => $stats_gen['firstBirth'] ?? (int)$stats_gen['firstEstimatedBirth'], |
|
132 | + 'gen_max_birth' => $stats_gen['lastBirth'] ?? (int)$stats_gen['lastEstimatedBirth'], |
|
134 | 133 | 'theoretical' => BigInteger::of(2)->power($gen - 1)->toInt(), |
135 | - 'known' => (int) $stats_gen['sosaCount'], |
|
134 | + 'known' => (int)$stats_gen['sosaCount'], |
|
136 | 135 | 'perc_known' => $this->safeDivision( |
137 | - BigInteger::of((int) $stats_gen['sosaCount']), |
|
136 | + BigInteger::of((int)$stats_gen['sosaCount']), |
|
138 | 137 | BigInteger::of(2)->power($gen - 1) |
139 | 138 | ), |
140 | 139 | 'missing' => $gen > 1 ? |
141 | - 2 * (int) $stats_by_gen[$gen - 1]['sosaCount'] - (int) $stats_gen['sosaCount'] : |
|
142 | - 0, |
|
140 | + 2 * (int)$stats_by_gen[$gen - 1]['sosaCount'] - (int)$stats_gen['sosaCount'] : 0, |
|
143 | 141 | 'perc_missing' => $gen > 1 ? |
144 | 142 | 1 - $this->safeDivision( |
145 | - BigInteger::of((int) $stats_gen['sosaCount']), |
|
146 | - BigInteger::of(2 * (int) $stats_by_gen[$gen - 1]['sosaCount']) |
|
147 | - ) : |
|
148 | - 0, |
|
149 | - 'total_known' => (int) $stats_gen['sosaTotalCount'], |
|
143 | + BigInteger::of((int)$stats_gen['sosaCount']), |
|
144 | + BigInteger::of(2 * (int)$stats_by_gen[$gen - 1]['sosaCount']) |
|
145 | + ) : 0, |
|
146 | + 'total_known' => (int)$stats_gen['sosaTotalCount'], |
|
150 | 147 | 'perc_total_known' => $this->safeDivision( |
151 | - BigInteger::of((int) $stats_gen['sosaTotalCount']), |
|
148 | + BigInteger::of((int)$stats_gen['sosaTotalCount']), |
|
152 | 149 | BigInteger::of(2)->power($gen)->minus(1) |
153 | 150 | ), |
154 | 151 | 'different' => $gen_diff, |
155 | 152 | 'perc_different' => $this->safeDivision( |
156 | 153 | BigInteger::of($gen_diff), |
157 | - BigInteger::of((int) $stats_gen['sosaCount']) |
|
154 | + BigInteger::of((int)$stats_gen['sosaCount']) |
|
158 | 155 | ), |
159 | - 'total_different' => (int) $stats_gen['diffSosaTotalCount'] |
|
156 | + 'total_different' => (int)$stats_gen['diffSosaTotalCount'] |
|
160 | 157 | ); |
161 | 158 | } |
162 | 159 |
@@ -33,51 +33,51 @@ |
||
33 | 33 | */ |
34 | 34 | class PedigreeCollapseData implements RequestHandlerInterface |
35 | 35 | { |
36 | - /** |
|
37 | - * @var SosaModule|null $module |
|
38 | - */ |
|
39 | - private $module; |
|
36 | + /** |
|
37 | + * @var SosaModule|null $module |
|
38 | + */ |
|
39 | + private $module; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Constructor for PedigreeCollapseData Request Handler |
|
43 | - * |
|
44 | - * @param ModuleService $module_service |
|
45 | - */ |
|
46 | - public function __construct(ModuleService $module_service) |
|
47 | - { |
|
48 | - $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
49 | - } |
|
41 | + /** |
|
42 | + * Constructor for PedigreeCollapseData Request Handler |
|
43 | + * |
|
44 | + * @param ModuleService $module_service |
|
45 | + */ |
|
46 | + public function __construct(ModuleService $module_service) |
|
47 | + { |
|
48 | + $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * {@inheritDoc} |
|
53 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
54 | - */ |
|
55 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
56 | - { |
|
57 | - if ($this->module === null) { |
|
58 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
59 | - } |
|
51 | + /** |
|
52 | + * {@inheritDoc} |
|
53 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
54 | + */ |
|
55 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
56 | + { |
|
57 | + if ($this->module === null) { |
|
58 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
59 | + } |
|
60 | 60 | |
61 | - $tree = $request->getAttribute('tree'); |
|
62 | - assert($tree instanceof Tree); |
|
61 | + $tree = $request->getAttribute('tree'); |
|
62 | + assert($tree instanceof Tree); |
|
63 | 63 | |
64 | - $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
|
64 | + $user = Auth::check() ? $request->getAttribute('user') : new DefaultUser(); |
|
65 | 65 | |
66 | - /** @var SosaStatisticsService $sosa_stats_service */ |
|
67 | - $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
|
68 | - $pedi_collapse_data = $sosa_stats_service->pedigreeCollapseByGenerationData(); |
|
66 | + /** @var SosaStatisticsService $sosa_stats_service */ |
|
67 | + $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
|
68 | + $pedi_collapse_data = $sosa_stats_service->pedigreeCollapseByGenerationData(); |
|
69 | 69 | |
70 | - $response = [ 'cells' => [] ]; |
|
71 | - $last_pedi_collapse = 0; |
|
72 | - foreach ($pedi_collapse_data as $gen => $rec) { |
|
73 | - $response['cells'][$gen] = view($this->module->name() . '::components/pedigree-collapse-cell', [ |
|
74 | - 'pedi_collapse_roots' => $rec['pedi_collapse_roots'], |
|
75 | - 'pedi_collapse_xgen' => $rec['pedi_collapse_xgen'] |
|
76 | - ]); |
|
77 | - $last_pedi_collapse = $rec['pedi_collapse_roots']; |
|
78 | - } |
|
79 | - $response['pedi_collapse'] = I18N::percentage($last_pedi_collapse, 2); |
|
70 | + $response = [ 'cells' => [] ]; |
|
71 | + $last_pedi_collapse = 0; |
|
72 | + foreach ($pedi_collapse_data as $gen => $rec) { |
|
73 | + $response['cells'][$gen] = view($this->module->name() . '::components/pedigree-collapse-cell', [ |
|
74 | + 'pedi_collapse_roots' => $rec['pedi_collapse_roots'], |
|
75 | + 'pedi_collapse_xgen' => $rec['pedi_collapse_xgen'] |
|
76 | + ]); |
|
77 | + $last_pedi_collapse = $rec['pedi_collapse_roots']; |
|
78 | + } |
|
79 | + $response['pedi_collapse'] = I18N::percentage($last_pedi_collapse, 2); |
|
80 | 80 | |
81 | - return response($response, StatusCodeInterface::STATUS_OK); |
|
82 | - } |
|
81 | + return response($response, StatusCodeInterface::STATUS_OK); |
|
82 | + } |
|
83 | 83 | } |
@@ -67,10 +67,10 @@ |
||
67 | 67 | $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
68 | 68 | $pedi_collapse_data = $sosa_stats_service->pedigreeCollapseByGenerationData(); |
69 | 69 | |
70 | - $response = [ 'cells' => [] ]; |
|
70 | + $response = ['cells' => []]; |
|
71 | 71 | $last_pedi_collapse = 0; |
72 | 72 | foreach ($pedi_collapse_data as $gen => $rec) { |
73 | - $response['cells'][$gen] = view($this->module->name() . '::components/pedigree-collapse-cell', [ |
|
73 | + $response['cells'][$gen] = view($this->module->name().'::components/pedigree-collapse-cell', [ |
|
74 | 74 | 'pedi_collapse_roots' => $rec['pedi_collapse_roots'], |
75 | 75 | 'pedi_collapse_xgen' => $rec['pedi_collapse_xgen'] |
76 | 76 | ]); |
@@ -30,52 +30,52 @@ |
||
30 | 30 | */ |
31 | 31 | class SosaConfigAction implements RequestHandlerInterface |
32 | 32 | { |
33 | - /** |
|
34 | - * @var UserService $user_service |
|
35 | - */ |
|
36 | - private $user_service; |
|
33 | + /** |
|
34 | + * @var UserService $user_service |
|
35 | + */ |
|
36 | + private $user_service; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Constructor for SosaConfigAction Request Handler |
|
40 | - * |
|
41 | - * @param UserService $user_service |
|
42 | - */ |
|
43 | - public function __construct(UserService $user_service) |
|
44 | - { |
|
45 | - $this->user_service = $user_service; |
|
46 | - } |
|
38 | + /** |
|
39 | + * Constructor for SosaConfigAction Request Handler |
|
40 | + * |
|
41 | + * @param UserService $user_service |
|
42 | + */ |
|
43 | + public function __construct(UserService $user_service) |
|
44 | + { |
|
45 | + $this->user_service = $user_service; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * {@inheritDoc} |
|
50 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
51 | - */ |
|
52 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
53 | - { |
|
54 | - $tree = $request->getAttribute('tree'); |
|
55 | - assert($tree instanceof Tree); |
|
48 | + /** |
|
49 | + * {@inheritDoc} |
|
50 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
51 | + */ |
|
52 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
53 | + { |
|
54 | + $tree = $request->getAttribute('tree'); |
|
55 | + assert($tree instanceof Tree); |
|
56 | 56 | |
57 | - $params = $request->getParsedBody(); |
|
58 | - assert(is_array($params)); |
|
57 | + $params = $request->getParsedBody(); |
|
58 | + assert(is_array($params)); |
|
59 | 59 | |
60 | - $user_id = (int) $params['sosa-userid']; |
|
61 | - $root_id = $params['sosa-rootid'] ?? ''; |
|
62 | - $max_gen = $params['sosa-maxgen'] ?? ''; |
|
60 | + $user_id = (int) $params['sosa-userid']; |
|
61 | + $root_id = $params['sosa-rootid'] ?? ''; |
|
62 | + $max_gen = $params['sosa-maxgen'] ?? ''; |
|
63 | 63 | |
64 | - if (Auth::id() == $user_id || ($user_id == -1 && Auth::isManager($tree))) { |
|
65 | - $user = $user_id == -1 ? new DefaultUser() : $this->user_service->find($user_id); |
|
66 | - if ($user !== null && ($root_indi = Registry::individualFactory()->make($root_id, $tree)) !== null) { |
|
67 | - $tree->setUserPreference($user, 'MAJ_SOSA_ROOT_ID', $root_indi->xref()); |
|
68 | - $tree->setUserPreference($user, 'MAJ_SOSA_MAX_GEN', $max_gen); |
|
69 | - FlashMessages::addMessage(I18N::translate('The root individual has been updated.')); |
|
70 | - return redirect(route(SosaConfig::class, [ |
|
71 | - 'tree' => $tree->name(), |
|
72 | - 'compute' => 'yes', |
|
73 | - 'user_id' => $user_id |
|
74 | - ])); |
|
75 | - } |
|
76 | - } |
|
64 | + if (Auth::id() == $user_id || ($user_id == -1 && Auth::isManager($tree))) { |
|
65 | + $user = $user_id == -1 ? new DefaultUser() : $this->user_service->find($user_id); |
|
66 | + if ($user !== null && ($root_indi = Registry::individualFactory()->make($root_id, $tree)) !== null) { |
|
67 | + $tree->setUserPreference($user, 'MAJ_SOSA_ROOT_ID', $root_indi->xref()); |
|
68 | + $tree->setUserPreference($user, 'MAJ_SOSA_MAX_GEN', $max_gen); |
|
69 | + FlashMessages::addMessage(I18N::translate('The root individual has been updated.')); |
|
70 | + return redirect(route(SosaConfig::class, [ |
|
71 | + 'tree' => $tree->name(), |
|
72 | + 'compute' => 'yes', |
|
73 | + 'user_id' => $user_id |
|
74 | + ])); |
|
75 | + } |
|
76 | + } |
|
77 | 77 | |
78 | - FlashMessages::addMessage(I18N::translate('The root individual could not be updated.'), 'danger'); |
|
79 | - return redirect(route(SosaConfig::class, ['tree' => $tree->name()])); |
|
80 | - } |
|
78 | + FlashMessages::addMessage(I18N::translate('The root individual could not be updated.'), 'danger'); |
|
79 | + return redirect(route(SosaConfig::class, ['tree' => $tree->name()])); |
|
80 | + } |
|
81 | 81 | } |
@@ -57,7 +57,7 @@ |
||
57 | 57 | $params = $request->getParsedBody(); |
58 | 58 | assert(is_array($params)); |
59 | 59 | |
60 | - $user_id = (int) $params['sosa-userid']; |
|
60 | + $user_id = (int)$params['sosa-userid']; |
|
61 | 61 | $root_id = $params['sosa-rootid'] ?? ''; |
62 | 62 | $max_gen = $params['sosa-maxgen'] ?? ''; |
63 | 63 |