@@ -19,10 +19,10 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | interface ModuleGeoAnalysisProviderInterface |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * List geographical analyses provided by the module as an array. |
|
| 24 | - * |
|
| 25 | - * @return string[] List of geographical analyses |
|
| 26 | - */ |
|
| 27 | - public function listGeoAnalyses(): array; |
|
| 22 | + /** |
|
| 23 | + * List geographical analyses provided by the module as an array. |
|
| 24 | + * |
|
| 25 | + * @return string[] List of geographical analyses |
|
| 26 | + */ |
|
| 27 | + public function listGeoAnalyses(): array; |
|
| 28 | 28 | } |
@@ -19,10 +19,10 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | interface ModuleMapDefinitionProviderInterface |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * List map definitions provided by the module as an array. |
|
| 24 | - * |
|
| 25 | - * @return array<int, MapDefinitionInterface> List of map definitions |
|
| 26 | - */ |
|
| 27 | - public function listMapDefinition(): array; |
|
| 22 | + /** |
|
| 23 | + * List map definitions provided by the module as an array. |
|
| 24 | + * |
|
| 25 | + * @return array<int, MapDefinitionInterface> List of map definitions |
|
| 26 | + */ |
|
| 27 | + public function listMapDefinition(): array; |
|
| 28 | 28 | } |
@@ -22,20 +22,20 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | interface ConfigurableTaskInterface |
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * Returns the HTML code to display the specific task configuration. |
|
| 27 | - * |
|
| 28 | - * @param ServerRequestInterface $request |
|
| 29 | - * @return string HTML code |
|
| 30 | - */ |
|
| 31 | - public function configView(ServerRequestInterface $request): string; |
|
| 25 | + /** |
|
| 26 | + * Returns the HTML code to display the specific task configuration. |
|
| 27 | + * |
|
| 28 | + * @param ServerRequestInterface $request |
|
| 29 | + * @return string HTML code |
|
| 30 | + */ |
|
| 31 | + public function configView(ServerRequestInterface $request): string; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Update the specific configuration of the task. |
|
| 35 | - * |
|
| 36 | - * @param ServerRequestInterface $request |
|
| 37 | - * @param TaskSchedule $task_schedule |
|
| 38 | - * @return bool Result of the update |
|
| 39 | - */ |
|
| 40 | - public function updateConfig(ServerRequestInterface $request, TaskSchedule $task_schedule): bool; |
|
| 33 | + /** |
|
| 34 | + * Update the specific configuration of the task. |
|
| 35 | + * |
|
| 36 | + * @param ServerRequestInterface $request |
|
| 37 | + * @param TaskSchedule $task_schedule |
|
| 38 | + * @return bool Result of the update |
|
| 39 | + */ |
|
| 40 | + public function updateConfig(ServerRequestInterface $request, TaskSchedule $task_schedule): bool; |
|
| 41 | 41 | } |
@@ -19,11 +19,11 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | interface ModuleTasksProviderInterface |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * List tasks provided by the module as an associative array. |
|
| 24 | - * They keys are used as task IDs for storage and reference. |
|
| 25 | - * |
|
| 26 | - * @return array<string, string> List of tasks |
|
| 27 | - */ |
|
| 28 | - public function listTasks(): array; |
|
| 22 | + /** |
|
| 23 | + * List tasks provided by the module as an associative array. |
|
| 24 | + * They keys are used as task IDs for storage and reference. |
|
| 25 | + * |
|
| 26 | + * @return array<string, string> List of tasks |
|
| 27 | + */ |
|
| 28 | + public function listTasks(): array; |
|
| 29 | 29 | } |
@@ -21,12 +21,12 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class Migration0 implements MigrationInterface |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * {@inheritDoc} |
|
| 26 | - * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade() |
|
| 27 | - */ |
|
| 28 | - public function upgrade(): void |
|
| 29 | - { |
|
| 30 | - // These migrations have been merged into migration 2. |
|
| 31 | - } |
|
| 24 | + /** |
|
| 25 | + * {@inheritDoc} |
|
| 26 | + * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade() |
|
| 27 | + */ |
|
| 28 | + public function upgrade(): void |
|
| 29 | + { |
|
| 30 | + // These migrations have been merged into migration 2. |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -21,12 +21,12 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class Migration1 implements MigrationInterface |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * {@inheritDoc} |
|
| 26 | - * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade() |
|
| 27 | - */ |
|
| 28 | - public function upgrade(): void |
|
| 29 | - { |
|
| 30 | - // These migrations have been merged into migration 2. |
|
| 31 | - } |
|
| 24 | + /** |
|
| 25 | + * {@inheritDoc} |
|
| 26 | + * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade() |
|
| 27 | + */ |
|
| 28 | + public function upgrade(): void |
|
| 29 | + { |
|
| 30 | + // These migrations have been merged into migration 2. |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -34,48 +34,48 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | class AncestorsList implements RequestHandlerInterface |
| 36 | 36 | { |
| 37 | - use ViewResponseTrait; |
|
| 37 | + use ViewResponseTrait; |
|
| 38 | 38 | |
| 39 | - private ?SosaModule $module; |
|
| 39 | + private ?SosaModule $module; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Constructor for AncestorsList 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 AncestorsList 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 = Validator::attributes($request)->tree(); |
|
| 62 | - $user = Auth::check() ? Validator::attributes($request)->user() : new DefaultUser(); |
|
| 61 | + $tree = Validator::attributes($request)->tree(); |
|
| 62 | + $user = Auth::check() ? Validator::attributes($request)->user() : new DefaultUser(); |
|
| 63 | 63 | |
| 64 | - /** @var SosaStatisticsService $sosa_stats_service */ |
|
| 65 | - $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
|
| 64 | + /** @var SosaStatisticsService $sosa_stats_service */ |
|
| 65 | + $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
|
| 66 | 66 | |
| 67 | - $current_gen = Validator::queryParams($request)->integer( |
|
| 68 | - 'gen', |
|
| 69 | - Validator::attributes($request)->integer('gen', 0) |
|
| 70 | - ); |
|
| 67 | + $current_gen = Validator::queryParams($request)->integer( |
|
| 68 | + 'gen', |
|
| 69 | + Validator::attributes($request)->integer('gen', 0) |
|
| 70 | + ); |
|
| 71 | 71 | |
| 72 | - return $this->viewResponse($this->module->name() . '::list-ancestors-page', [ |
|
| 73 | - 'module_name' => $this->module->name(), |
|
| 74 | - 'title' => I18N::translate('Sosa Ancestors'), |
|
| 75 | - 'tree' => $tree, |
|
| 76 | - 'root_indi' => $sosa_stats_service->rootIndividual(), |
|
| 77 | - 'max_gen' => $sosa_stats_service->maxGeneration(), |
|
| 78 | - 'current_gen' => $current_gen |
|
| 79 | - ]); |
|
| 80 | - } |
|
| 72 | + return $this->viewResponse($this->module->name() . '::list-ancestors-page', [ |
|
| 73 | + 'module_name' => $this->module->name(), |
|
| 74 | + 'title' => I18N::translate('Sosa Ancestors'), |
|
| 75 | + 'tree' => $tree, |
|
| 76 | + 'root_indi' => $sosa_stats_service->rootIndividual(), |
|
| 77 | + 'max_gen' => $sosa_stats_service->maxGeneration(), |
|
| 78 | + 'current_gen' => $current_gen |
|
| 79 | + ]); |
|
| 80 | + } |
|
| 81 | 81 | } |
@@ -69,7 +69,7 @@ |
||
| 69 | 69 | Validator::attributes($request)->integer('gen', 0) |
| 70 | 70 | ); |
| 71 | 71 | |
| 72 | - return $this->viewResponse($this->module->name() . '::list-ancestors-page', [ |
|
| 72 | + return $this->viewResponse($this->module->name().'::list-ancestors-page', [ |
|
| 73 | 73 | 'module_name' => $this->module->name(), |
| 74 | 74 | 'title' => I18N::translate('Sosa Ancestors'), |
| 75 | 75 | 'tree' => $tree, |
@@ -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, |
@@ -33,71 +33,71 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | class SosaConfig 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 | - * Constructor for SosaConfig Request Handler |
|
| 45 | - * |
|
| 46 | - * @param ModuleService $module_service |
|
| 47 | - */ |
|
| 48 | - public function __construct(ModuleService $module_service) |
|
| 49 | - { |
|
| 50 | - $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
| 51 | - } |
|
| 43 | + /** |
|
| 44 | + * Constructor for SosaConfig Request Handler |
|
| 45 | + * |
|
| 46 | + * @param ModuleService $module_service |
|
| 47 | + */ |
|
| 48 | + public function __construct(ModuleService $module_service) |
|
| 49 | + { |
|
| 50 | + $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * {@inheritDoc} |
|
| 55 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
| 56 | - */ |
|
| 57 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
| 58 | - { |
|
| 59 | - if ($this->module === null) { |
|
| 60 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
| 61 | - } |
|
| 53 | + /** |
|
| 54 | + * {@inheritDoc} |
|
| 55 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
| 56 | + */ |
|
| 57 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
| 58 | + { |
|
| 59 | + if ($this->module === null) { |
|
| 60 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - $tree = Validator::attributes($request)->tree(); |
|
| 63 | + $tree = Validator::attributes($request)->tree(); |
|
| 64 | 64 | |
| 65 | - $users_root = array(); |
|
| 66 | - if (Auth::check()) { |
|
| 67 | - /** @var \Fisharebest\Webtrees\User $user */ |
|
| 68 | - $user = Auth::user(); |
|
| 69 | - $users_root[] = [ |
|
| 70 | - 'user' => $user, |
|
| 71 | - 'root_id' => $tree->getUserPreference($user, 'MAJ_SOSA_ROOT_ID'), |
|
| 72 | - 'max_gen' => $tree->getUserPreference($user, 'MAJ_SOSA_MAX_GEN') |
|
| 73 | - ]; |
|
| 65 | + $users_root = array(); |
|
| 66 | + if (Auth::check()) { |
|
| 67 | + /** @var \Fisharebest\Webtrees\User $user */ |
|
| 68 | + $user = Auth::user(); |
|
| 69 | + $users_root[] = [ |
|
| 70 | + 'user' => $user, |
|
| 71 | + 'root_id' => $tree->getUserPreference($user, 'MAJ_SOSA_ROOT_ID'), |
|
| 72 | + 'max_gen' => $tree->getUserPreference($user, 'MAJ_SOSA_MAX_GEN') |
|
| 73 | + ]; |
|
| 74 | 74 | |
| 75 | - if (Auth::isManager($tree)) { |
|
| 76 | - $default_user = new DefaultUser(); |
|
| 77 | - $users_root[] = [ |
|
| 78 | - 'user' => $default_user, |
|
| 79 | - 'root_id' => $tree->getUserPreference($default_user, 'MAJ_SOSA_ROOT_ID'), |
|
| 80 | - 'max_gen' => $tree->getUserPreference($default_user, 'MAJ_SOSA_MAX_GEN') |
|
| 81 | - ]; |
|
| 82 | - } |
|
| 83 | - } |
|
| 75 | + if (Auth::isManager($tree)) { |
|
| 76 | + $default_user = new DefaultUser(); |
|
| 77 | + $users_root[] = [ |
|
| 78 | + 'user' => $default_user, |
|
| 79 | + 'root_id' => $tree->getUserPreference($default_user, 'MAJ_SOSA_ROOT_ID'), |
|
| 80 | + 'max_gen' => $tree->getUserPreference($default_user, 'MAJ_SOSA_MAX_GEN') |
|
| 81 | + ]; |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - // Use the system max generations if not set |
|
| 86 | - $max_gen_system = app(SosaRecordsService::class)->maxSystemGenerations(); |
|
| 87 | - foreach ($users_root as $key => $user_root) { |
|
| 88 | - $users_root[$key]['max_gen'] = is_numeric($user_root['max_gen']) ? |
|
| 89 | - (int) $user_root['max_gen'] : |
|
| 90 | - $max_gen_system; |
|
| 91 | - }; |
|
| 85 | + // Use the system max generations if not set |
|
| 86 | + $max_gen_system = app(SosaRecordsService::class)->maxSystemGenerations(); |
|
| 87 | + foreach ($users_root as $key => $user_root) { |
|
| 88 | + $users_root[$key]['max_gen'] = is_numeric($user_root['max_gen']) ? |
|
| 89 | + (int) $user_root['max_gen'] : |
|
| 90 | + $max_gen_system; |
|
| 91 | + }; |
|
| 92 | 92 | |
| 93 | - return $this->viewResponse($this->module->name() . '::config-page', [ |
|
| 94 | - 'module_name' => $this->module->name(), |
|
| 95 | - 'title' => I18N::translate('Sosa Configuration'), |
|
| 96 | - 'tree' => $tree, |
|
| 97 | - 'user_id' => Validator::attributes($request)->user(), |
|
| 98 | - 'selected_user_id' => Validator::queryParams($request)->integer('user_id', 0), |
|
| 99 | - 'immediate_compute' => Validator::queryParams($request)->string('compute', '') === 'yes', |
|
| 100 | - 'users_root' => $users_root |
|
| 101 | - ]); |
|
| 102 | - } |
|
| 93 | + return $this->viewResponse($this->module->name() . '::config-page', [ |
|
| 94 | + 'module_name' => $this->module->name(), |
|
| 95 | + 'title' => I18N::translate('Sosa Configuration'), |
|
| 96 | + 'tree' => $tree, |
|
| 97 | + 'user_id' => Validator::attributes($request)->user(), |
|
| 98 | + 'selected_user_id' => Validator::queryParams($request)->integer('user_id', 0), |
|
| 99 | + 'immediate_compute' => Validator::queryParams($request)->string('compute', '') === 'yes', |
|
| 100 | + 'users_root' => $users_root |
|
| 101 | + ]); |
|
| 102 | + } |
|
| 103 | 103 | } |
@@ -37,89 +37,89 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | class MissingAncestorsList implements RequestHandlerInterface |
| 39 | 39 | { |
| 40 | - use ViewResponseTrait; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @var SosaModule|null $module |
|
| 44 | - */ |
|
| 45 | - private $module; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @var SosaRecordsService $sosa_record_service |
|
| 49 | - */ |
|
| 50 | - private $sosa_record_service; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Constructor for MissingAncestorsList Request Handler |
|
| 54 | - * |
|
| 55 | - * @param ModuleService $module_service |
|
| 56 | - * @param SosaRecordsService $sosa_record_service |
|
| 57 | - */ |
|
| 58 | - public function __construct( |
|
| 59 | - ModuleService $module_service, |
|
| 60 | - SosaRecordsService $sosa_record_service |
|
| 61 | - ) { |
|
| 62 | - $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
| 63 | - $this->sosa_record_service = $sosa_record_service; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * {@inheritDoc} |
|
| 68 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
| 69 | - */ |
|
| 70 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
| 71 | - { |
|
| 72 | - if ($this->module === null) { |
|
| 73 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - $tree = Validator::attributes($request)->tree(); |
|
| 77 | - $user = Auth::check() ? Validator::attributes($request)->user() : new DefaultUser(); |
|
| 78 | - |
|
| 79 | - /** @var SosaStatisticsService $sosa_stats_service */ |
|
| 80 | - $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
|
| 81 | - |
|
| 82 | - $current_gen = Validator::queryParams($request)->integer( |
|
| 83 | - 'gen', |
|
| 84 | - Validator::attributes($request)->integer('gen', 0) |
|
| 85 | - ); |
|
| 86 | - |
|
| 87 | - $list_missing = $this->sosa_record_service->listMissingAncestorsAtGeneration($tree, $user, $current_gen); |
|
| 88 | - $nb_missing_diff = $list_missing->sum(function (stdClass $value): int { |
|
| 89 | - return ($value->majs_fat_id === null ? 1 : 0) + ($value->majs_mot_id === null ? 1 : 0); |
|
| 90 | - }); |
|
| 91 | - |
|
| 92 | - $list_missing = $list_missing->map(function (stdClass $value) use ($tree): ?MissingAncestor { |
|
| 93 | - $indi = Registry::individualFactory()->make($value->majs_i_id, $tree); |
|
| 94 | - if ($indi !== null && $indi->canShowName()) { |
|
| 95 | - return new MissingAncestor( |
|
| 96 | - $indi, |
|
| 97 | - (int) $value->majs_sosa, |
|
| 98 | - $value->majs_fat_id === null, |
|
| 99 | - $value->majs_mot_id === null |
|
| 100 | - ); |
|
| 101 | - } |
|
| 102 | - return null; |
|
| 103 | - })->filter(); |
|
| 104 | - |
|
| 105 | - $nb_missing_shown = $list_missing->sum(function (MissingAncestor $value): int { |
|
| 106 | - return ($value->isFatherMissing() ? 1 : 0) + ($value->isMotherMissing() ? 1 : 0); |
|
| 107 | - }); |
|
| 108 | - |
|
| 109 | - return $this->viewResponse($this->module->name() . '::list-missing-page', [ |
|
| 110 | - 'module_name' => $this->module->name(), |
|
| 111 | - 'title' => I18N::translate('Missing Ancestors'), |
|
| 112 | - 'tree' => $tree, |
|
| 113 | - 'root_indi' => $sosa_stats_service->rootIndividual(), |
|
| 114 | - 'max_gen' => $sosa_stats_service->maxGeneration(), |
|
| 115 | - 'current_gen' => $current_gen, |
|
| 116 | - 'list_missing' => $list_missing, |
|
| 117 | - 'nb_missing_diff' => $nb_missing_diff, |
|
| 118 | - 'nb_missing_shown' => $nb_missing_shown, |
|
| 119 | - 'gen_completeness' => |
|
| 120 | - $sosa_stats_service->totalAncestorsAtGeneration($current_gen) / pow(2, $current_gen - 1), |
|
| 121 | - 'gen_potential' => |
|
| 122 | - $sosa_stats_service->totalAncestorsAtGeneration($current_gen - 1) / pow(2, $current_gen - 2) |
|
| 123 | - ]); |
|
| 124 | - } |
|
| 40 | + use ViewResponseTrait; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @var SosaModule|null $module |
|
| 44 | + */ |
|
| 45 | + private $module; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @var SosaRecordsService $sosa_record_service |
|
| 49 | + */ |
|
| 50 | + private $sosa_record_service; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Constructor for MissingAncestorsList Request Handler |
|
| 54 | + * |
|
| 55 | + * @param ModuleService $module_service |
|
| 56 | + * @param SosaRecordsService $sosa_record_service |
|
| 57 | + */ |
|
| 58 | + public function __construct( |
|
| 59 | + ModuleService $module_service, |
|
| 60 | + SosaRecordsService $sosa_record_service |
|
| 61 | + ) { |
|
| 62 | + $this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
| 63 | + $this->sosa_record_service = $sosa_record_service; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * {@inheritDoc} |
|
| 68 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
| 69 | + */ |
|
| 70 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
| 71 | + { |
|
| 72 | + if ($this->module === null) { |
|
| 73 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + $tree = Validator::attributes($request)->tree(); |
|
| 77 | + $user = Auth::check() ? Validator::attributes($request)->user() : new DefaultUser(); |
|
| 78 | + |
|
| 79 | + /** @var SosaStatisticsService $sosa_stats_service */ |
|
| 80 | + $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
|
| 81 | + |
|
| 82 | + $current_gen = Validator::queryParams($request)->integer( |
|
| 83 | + 'gen', |
|
| 84 | + Validator::attributes($request)->integer('gen', 0) |
|
| 85 | + ); |
|
| 86 | + |
|
| 87 | + $list_missing = $this->sosa_record_service->listMissingAncestorsAtGeneration($tree, $user, $current_gen); |
|
| 88 | + $nb_missing_diff = $list_missing->sum(function (stdClass $value): int { |
|
| 89 | + return ($value->majs_fat_id === null ? 1 : 0) + ($value->majs_mot_id === null ? 1 : 0); |
|
| 90 | + }); |
|
| 91 | + |
|
| 92 | + $list_missing = $list_missing->map(function (stdClass $value) use ($tree): ?MissingAncestor { |
|
| 93 | + $indi = Registry::individualFactory()->make($value->majs_i_id, $tree); |
|
| 94 | + if ($indi !== null && $indi->canShowName()) { |
|
| 95 | + return new MissingAncestor( |
|
| 96 | + $indi, |
|
| 97 | + (int) $value->majs_sosa, |
|
| 98 | + $value->majs_fat_id === null, |
|
| 99 | + $value->majs_mot_id === null |
|
| 100 | + ); |
|
| 101 | + } |
|
| 102 | + return null; |
|
| 103 | + })->filter(); |
|
| 104 | + |
|
| 105 | + $nb_missing_shown = $list_missing->sum(function (MissingAncestor $value): int { |
|
| 106 | + return ($value->isFatherMissing() ? 1 : 0) + ($value->isMotherMissing() ? 1 : 0); |
|
| 107 | + }); |
|
| 108 | + |
|
| 109 | + return $this->viewResponse($this->module->name() . '::list-missing-page', [ |
|
| 110 | + 'module_name' => $this->module->name(), |
|
| 111 | + 'title' => I18N::translate('Missing Ancestors'), |
|
| 112 | + 'tree' => $tree, |
|
| 113 | + 'root_indi' => $sosa_stats_service->rootIndividual(), |
|
| 114 | + 'max_gen' => $sosa_stats_service->maxGeneration(), |
|
| 115 | + 'current_gen' => $current_gen, |
|
| 116 | + 'list_missing' => $list_missing, |
|
| 117 | + 'nb_missing_diff' => $nb_missing_diff, |
|
| 118 | + 'nb_missing_shown' => $nb_missing_shown, |
|
| 119 | + 'gen_completeness' => |
|
| 120 | + $sosa_stats_service->totalAncestorsAtGeneration($current_gen) / pow(2, $current_gen - 1), |
|
| 121 | + 'gen_potential' => |
|
| 122 | + $sosa_stats_service->totalAncestorsAtGeneration($current_gen - 1) / pow(2, $current_gen - 2) |
|
| 123 | + ]); |
|
| 124 | + } |
|
| 125 | 125 | } |
@@ -79,22 +79,22 @@ discard block |
||
| 79 | 79 | /** @var SosaStatisticsService $sosa_stats_service */ |
| 80 | 80 | $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
| 81 | 81 | |
| 82 | - $current_gen = Validator::queryParams($request)->integer( |
|
| 82 | + $current_gen = Validator::queryParams($request)->integer( |
|
| 83 | 83 | 'gen', |
| 84 | 84 | Validator::attributes($request)->integer('gen', 0) |
| 85 | 85 | ); |
| 86 | 86 | |
| 87 | 87 | $list_missing = $this->sosa_record_service->listMissingAncestorsAtGeneration($tree, $user, $current_gen); |
| 88 | - $nb_missing_diff = $list_missing->sum(function (stdClass $value): int { |
|
| 88 | + $nb_missing_diff = $list_missing->sum(function(stdClass $value): int { |
|
| 89 | 89 | return ($value->majs_fat_id === null ? 1 : 0) + ($value->majs_mot_id === null ? 1 : 0); |
| 90 | 90 | }); |
| 91 | 91 | |
| 92 | - $list_missing = $list_missing->map(function (stdClass $value) use ($tree): ?MissingAncestor { |
|
| 92 | + $list_missing = $list_missing->map(function(stdClass $value) use ($tree): ?MissingAncestor { |
|
| 93 | 93 | $indi = Registry::individualFactory()->make($value->majs_i_id, $tree); |
| 94 | 94 | if ($indi !== null && $indi->canShowName()) { |
| 95 | 95 | return new MissingAncestor( |
| 96 | 96 | $indi, |
| 97 | - (int) $value->majs_sosa, |
|
| 97 | + (int)$value->majs_sosa, |
|
| 98 | 98 | $value->majs_fat_id === null, |
| 99 | 99 | $value->majs_mot_id === null |
| 100 | 100 | ); |
@@ -102,11 +102,11 @@ discard block |
||
| 102 | 102 | return null; |
| 103 | 103 | })->filter(); |
| 104 | 104 | |
| 105 | - $nb_missing_shown = $list_missing->sum(function (MissingAncestor $value): int { |
|
| 105 | + $nb_missing_shown = $list_missing->sum(function(MissingAncestor $value): int { |
|
| 106 | 106 | return ($value->isFatherMissing() ? 1 : 0) + ($value->isMotherMissing() ? 1 : 0); |
| 107 | 107 | }); |
| 108 | 108 | |
| 109 | - return $this->viewResponse($this->module->name() . '::list-missing-page', [ |
|
| 109 | + return $this->viewResponse($this->module->name().'::list-missing-page', [ |
|
| 110 | 110 | 'module_name' => $this->module->name(), |
| 111 | 111 | 'title' => I18N::translate('Missing Ancestors'), |
| 112 | 112 | 'tree' => $tree, |