Passed
Branch feature/2.0 (d2af8f)
by Jonathan
13:07
created
src/Webtrees/Module/Sosa/Http/RequestHandlers/SosaComputeAction.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -32,48 +32,48 @@
 block discarded – undo
32 32
  */
33 33
 class SosaComputeAction implements RequestHandlerInterface
34 34
 {
35
-    /**
36
-     * @var UserService $user_service
37
-     */
38
-    private $user_service;
35
+	/**
36
+	 * @var UserService $user_service
37
+	 */
38
+	private $user_service;
39 39
     
40
-    /**
41
-     * Constructor for SosaConfigAction Request Handler
42
-     * 
43
-     * @param UserService $user_service
44
-     */
45
-    public function __construct(UserService $user_service)
46
-    {
47
-        $this->user_service = $user_service;
48
-    }
40
+	/**
41
+	 * Constructor for SosaConfigAction Request Handler
42
+	 * 
43
+	 * @param UserService $user_service
44
+	 */
45
+	public function __construct(UserService $user_service)
46
+	{
47
+		$this->user_service = $user_service;
48
+	}
49 49
     
50
-    /**
51
-     * {@inheritDoc}
52
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
53
-     */
54
-    public function handle(ServerRequestInterface $request): ResponseInterface
55
-    {
56
-        $tree = $request->getAttribute('tree');
57
-        assert($tree instanceof Tree);
50
+	/**
51
+	 * {@inheritDoc}
52
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
53
+	 */
54
+	public function handle(ServerRequestInterface $request): ResponseInterface
55
+	{
56
+		$tree = $request->getAttribute('tree');
57
+		assert($tree instanceof Tree);
58 58
         
59
-        $user_id = (int) ($request->getParsedBody()['user_id'] ?? 0);
60
-        $partial_from = $request->getParsedBody()['partial_from'] ?? null;
59
+		$user_id = (int) ($request->getParsedBody()['user_id'] ?? 0);
60
+		$partial_from = $request->getParsedBody()['partial_from'] ?? null;
61 61
         
62
-        if(($user_id == -1 && Auth::isManager($tree)) || Auth::id() == $user_id) {
63
-            $user = $user_id == -1 ? new DefaultUser() : $this->user_service->find($user_id);
62
+		if(($user_id == -1 && Auth::isManager($tree)) || Auth::id() == $user_id) {
63
+			$user = $user_id == -1 ? new DefaultUser() : $this->user_service->find($user_id);
64 64
             
65
-            /** @var SosaCalculatorService $sosa_calc_service */
66
-            $sosa_calc_service = app()->makeWith(SosaCalculatorService::class, [ 'tree' => $tree, 'user' => $user]);
65
+			/** @var SosaCalculatorService $sosa_calc_service */
66
+			$sosa_calc_service = app()->makeWith(SosaCalculatorService::class, [ 'tree' => $tree, 'user' => $user]);
67 67
             
68
-            if($partial_from !== null && $sosa_from = Registry::individualFactory()->make($partial_from, $tree)) {
69
-                $res = $sosa_calc_service->computeFromIndividual($sosa_from);
70
-            } else {
71
-                $res = $sosa_calc_service->computeAll();
72
-            }
68
+			if($partial_from !== null && $sosa_from = Registry::individualFactory()->make($partial_from, $tree)) {
69
+				$res = $sosa_calc_service->computeFromIndividual($sosa_from);
70
+			} else {
71
+				$res = $sosa_calc_service->computeAll();
72
+			}
73 73
             
74
-            return $res ? response('', 200) : response(I18N::translate('An error occurred during Sosa computation.'), 500);
74
+			return $res ? response('', 200) : response(I18N::translate('An error occurred during Sosa computation.'), 500);
75 75
             
76
-        }
77
-        throw new HttpAccessDeniedException(I18N::translate("You do not have permission to modify the user"));
78
-    }
76
+		}
77
+		throw new HttpAccessDeniedException(I18N::translate("You do not have permission to modify the user"));
78
+	}
79 79
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Http/RequestHandlers/SosaConfig.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -32,58 +32,58 @@
 block discarded – undo
32 32
  */
33 33
 class SosaConfig implements RequestHandlerInterface
34 34
 {
35
-    use ViewResponseTrait;
35
+	use ViewResponseTrait;
36 36
     
37
-    /**
38
-     * @var SosaModule $module
39
-     */
40
-    private $module;
37
+	/**
38
+	 * @var SosaModule $module
39
+	 */
40
+	private $module;
41 41
     
42
-    /**
43
-     * Constructor for SosaConfig Request Handler
44
-     *
45
-     * @param ModuleService $module_service
46
-     */
47
-    public function __construct(
48
-        ModuleService $module_service
49
-    ) {
50
-        $this->module = $module_service->findByInterface(SosaModule::class)->first();
51
-    }
42
+	/**
43
+	 * Constructor for SosaConfig Request Handler
44
+	 *
45
+	 * @param ModuleService $module_service
46
+	 */
47
+	public function __construct(
48
+		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
-        /** @var Tree $tree */
64
-        $tree = $request->getAttribute('tree');
65
-        assert($tree instanceof Tree);
63
+		/** @var Tree $tree */
64
+		$tree = $request->getAttribute('tree');
65
+		assert($tree instanceof Tree);
66 66
         
67
-        $users_root = array();
68
-        if(Auth::check()) {
69
-            /** @var \Fisharebest\Webtrees\User $user */
70
-            $user = Auth::user();
71
-            $users_root[] = ['user' => $user, 'root_id' => $tree->getUserPreference($user, 'MAJ_SOSA_ROOT_ID')];
67
+		$users_root = array();
68
+		if(Auth::check()) {
69
+			/** @var \Fisharebest\Webtrees\User $user */
70
+			$user = Auth::user();
71
+			$users_root[] = ['user' => $user, 'root_id' => $tree->getUserPreference($user, 'MAJ_SOSA_ROOT_ID')];
72 72
             
73
-            if(Auth::isManager($tree)) {
74
-                $default_user = new DefaultUser();
75
-                $users_root[] = ['user' => $default_user, 'root_id' => $tree->getUserPreference($default_user, 'MAJ_SOSA_ROOT_ID')];
76
-            }
77
-        }
73
+			if(Auth::isManager($tree)) {
74
+				$default_user = new DefaultUser();
75
+				$users_root[] = ['user' => $default_user, 'root_id' => $tree->getUserPreference($default_user, 'MAJ_SOSA_ROOT_ID')];
76
+			}
77
+		}
78 78
         
79
-        return $this->viewResponse($this->module->name() . '::config-page', [
80
-            'module_name'       =>  $this->module->name(),
81
-            'title'             =>  I18N::translate('Sosa Configuration'),
82
-            'tree'              =>  $tree,
83
-            'user_id'           =>  $request->getAttribute('user'),
84
-            'selected_user_id'  =>  (int) ($request->getQueryParams()['user_id'] ?? 0),
85
-            'immediate_compute' =>  ($request->getQueryParams()['compute'] ?? '') == 'yes',
86
-            'users_root'        =>  $users_root
87
-        ]);
88
-    }
79
+		return $this->viewResponse($this->module->name() . '::config-page', [
80
+			'module_name'       =>  $this->module->name(),
81
+			'title'             =>  I18N::translate('Sosa Configuration'),
82
+			'tree'              =>  $tree,
83
+			'user_id'           =>  $request->getAttribute('user'),
84
+			'selected_user_id'  =>  (int) ($request->getQueryParams()['user_id'] ?? 0),
85
+			'immediate_compute' =>  ($request->getQueryParams()['compute'] ?? '') == 'yes',
86
+			'users_root'        =>  $users_root
87
+		]);
88
+	}
89 89
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Schema/Migration1.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@
 block discarded – undo
22 22
 class Migration1 implements MigrationInterface
23 23
 {
24 24
     
25
-    /**
26
-     * {@inheritDoc}
27
-     * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
28
-     */
29
-    public function upgrade(): void
30
-    {
31
-        // These migrations have been merged into migration 2.
32
-    }
25
+	/**
26
+	 * {@inheritDoc}
27
+	 * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
28
+	 */
29
+	public function upgrade(): void
30
+	{
31
+		// These migrations have been merged into migration 2.
32
+	}
33 33
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Schema/Migration0.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@
 block discarded – undo
22 22
 class Migration0 implements MigrationInterface
23 23
 {
24 24
     
25
-    /**
26
-     * {@inheritDoc}
27
-     * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
28
-     */
25
+	/**
26
+	 * {@inheritDoc}
27
+	 * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
28
+	 */
29 29
 	public function upgrade(): void
30 30
 	{
31
-	    // These migrations have been merged into migration 2.
31
+		// These migrations have been merged into migration 2.
32 32
 	}
33 33
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Schema/Migration2.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -23,36 +23,36 @@
 block discarded – undo
23 23
  */
24 24
 class Migration2 implements MigrationInterface {
25 25
     
26
-    /**
27
-     * {@inheritDoc}
28
-     * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
29
-     */
26
+	/**
27
+	 * {@inheritDoc}
28
+	 * @see \Fisharebest\Webtrees\Schema\MigrationInterface::upgrade()
29
+	 */
30 30
 	public function upgrade(): void
31 31
 	{
32 32
 	    
33
-	    // Clean up previous sosa table if it exists
34
-	    DB::schema()->dropIfExists('maj_sosa');
33
+		// Clean up previous sosa table if it exists
34
+		DB::schema()->dropIfExists('maj_sosa');
35 35
 	    
36
-	    DB::schema()->create('maj_sosa', static function (Blueprint $table): void {
36
+		DB::schema()->create('maj_sosa', static function (Blueprint $table): void {
37 37
 	        
38
-	        $table->integer('majs_gedcom_id');
39
-	        $table->integer('majs_user_id')->default(-1);
40
-	        $table->bigInteger('majs_sosa')->unsigned(); // Allow to calculate sosa on 64 generations
41
-	        $table->string('majs_i_id', 20);
42
-	        $table->tinyInteger('majs_gen')->nullable();
43
-	        $table->smallInteger('majs_birth_year')->nullable();
44
-	        $table->smallInteger('majs_birth_year_est')->nullable();
45
-	        $table->smallInteger('majs_death_year')->nullable();
46
-	        $table->smallInteger('majs_death_year_est')->nullable();
38
+			$table->integer('majs_gedcom_id');
39
+			$table->integer('majs_user_id')->default(-1);
40
+			$table->bigInteger('majs_sosa')->unsigned(); // Allow to calculate sosa on 64 generations
41
+			$table->string('majs_i_id', 20);
42
+			$table->tinyInteger('majs_gen')->nullable();
43
+			$table->smallInteger('majs_birth_year')->nullable();
44
+			$table->smallInteger('majs_birth_year_est')->nullable();
45
+			$table->smallInteger('majs_death_year')->nullable();
46
+			$table->smallInteger('majs_death_year_est')->nullable();
47 47
 	        
48
-	        $table->primary(['majs_gedcom_id', 'majs_user_id', 'majs_sosa']);
48
+			$table->primary(['majs_gedcom_id', 'majs_user_id', 'majs_sosa']);
49 49
 	        
50
-	        $table->index(['majs_gedcom_id', 'majs_user_id']);
51
-	        $table->index(['majs_gedcom_id', 'majs_user_id', 'majs_i_id']);
52
-	        $table->index(['majs_gedcom_id', 'majs_user_id', 'majs_gen']);
50
+			$table->index(['majs_gedcom_id', 'majs_user_id']);
51
+			$table->index(['majs_gedcom_id', 'majs_user_id', 'majs_i_id']);
52
+			$table->index(['majs_gedcom_id', 'majs_user_id', 'majs_gen']);
53 53
 	        
54
-	        $table->foreign('majs_gedcom_id')->references('gedcom_id')->on('gedcom')->onDelete('cascade');
55
-	        $table->foreign('majs_user_id')->references('user_id')->on('user')->onDelete('cascade');
56
-	    });
54
+			$table->foreign('majs_gedcom_id')->references('gedcom_id')->on('gedcom')->onDelete('cascade');
55
+			$table->foreign('majs_user_id')->references('user_id')->on('user')->onDelete('cascade');
56
+		});
57 57
 	}
58 58
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Services/SosaRecordsService.php 1 patch
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -26,130 +26,130 @@
 block discarded – undo
26 26
  */
27 27
 class SosaRecordsService
28 28
 {
29
-    /**
30
-     * Maximum number of generation the database is able to hold.
31
-     * @var int MAX_DB_GENERATIONS
32
-     */
33
-    public const MAX_DB_GENERATIONS = 64;
29
+	/**
30
+	 * Maximum number of generation the database is able to hold.
31
+	 * @var int MAX_DB_GENERATIONS
32
+	 */
33
+	public const MAX_DB_GENERATIONS = 64;
34 34
     
35
-    /**
36
-     * Calculate the generation of a sosa
37
-     * Sosa 1 is of generation 1.
38
-     *
39
-     * @param int $sosa
40
-     * @return int
41
-     */
42
-    public function generation(int $sosa) : int
43
-    {
44
-        return (int) log($sosa, 2) + 1;
45
-    }
35
+	/**
36
+	 * Calculate the generation of a sosa
37
+	 * Sosa 1 is of generation 1.
38
+	 *
39
+	 * @param int $sosa
40
+	 * @return int
41
+	 */
42
+	public function generation(int $sosa) : int
43
+	{
44
+		return (int) log($sosa, 2) + 1;
45
+	}
46 46
     
47
-    /**
48
-     * Returns all Sosa numbers associated to an Individual
49
-     * 
50
-     * @param Tree $tree
51
-     * @param User $user
52
-     * @param Individual $indi
53
-     * @return Collection
54
-     */
55
-    public function getSosaNumbers(Tree $tree, User $user, Individual $indi) : Collection
56
-    {
57
-        return DB::table('maj_sosa')
58
-            ->select(['majs_sosa', 'majs_gen'])
59
-            ->where('majs_gedcom_id', '=', $tree->id())
60
-            ->where('majs_user_id', '=', $user->id())
61
-            ->where('majs_i_id', '=', $indi->xref())
62
-            ->get()->pluck('majs_gen', 'majs_sosa');
63
-    }
47
+	/**
48
+	 * Returns all Sosa numbers associated to an Individual
49
+	 * 
50
+	 * @param Tree $tree
51
+	 * @param User $user
52
+	 * @param Individual $indi
53
+	 * @return Collection
54
+	 */
55
+	public function getSosaNumbers(Tree $tree, User $user, Individual $indi) : Collection
56
+	{
57
+		return DB::table('maj_sosa')
58
+			->select(['majs_sosa', 'majs_gen'])
59
+			->where('majs_gedcom_id', '=', $tree->id())
60
+			->where('majs_user_id', '=', $user->id())
61
+			->where('majs_i_id', '=', $indi->xref())
62
+			->get()->pluck('majs_gen', 'majs_sosa');
63
+	}
64 64
     
65
-    /**
66
-     * Remove all Sosa entries related to the gedcom file and user
67
-     * 
68
-     * @param Tree $tree
69
-     * @param User $user
70
-     */
71
-    public function deleteAll(Tree $tree, User $user) : void
72
-    {
73
-        DB::table('maj_sosa')
74
-            ->where('majs_gedcom_id', '=', $tree->id())
75
-            ->where('majs_user_id', '=', $user->id())
76
-            ->delete();
77
-    }
65
+	/**
66
+	 * Remove all Sosa entries related to the gedcom file and user
67
+	 * 
68
+	 * @param Tree $tree
69
+	 * @param User $user
70
+	 */
71
+	public function deleteAll(Tree $tree, User $user) : void
72
+	{
73
+		DB::table('maj_sosa')
74
+			->where('majs_gedcom_id', '=', $tree->id())
75
+			->where('majs_user_id', '=', $user->id())
76
+			->delete();
77
+	}
78 78
     
79
-    /**
80
-     * 
81
-     * @param Tree $tree
82
-     * @param User $user
83
-     * @param int $sosa
84
-     */
85
-    public function deleteAncestorsFrom(Tree $tree, User $user, int $sosa) : void
86
-    {
87
-        DB::table('maj_sosa')
88
-            ->where('majs_gedcom_id', '=', $tree->id())
89
-            ->where('majs_user_id', '=', $user->id())
90
-            ->where('majs_sosa', '>=', $sosa)
91
-            ->whereRaw(
92
-                'FLOOR(majs_sosa / (POW(2, (majs_gen - :gen)))) = :sosa',
93
-                ['gen' => $this->generation($sosa), 'sosa' => $sosa])
94
-            ->delete();
95
-    }
79
+	/**
80
+	 * 
81
+	 * @param Tree $tree
82
+	 * @param User $user
83
+	 * @param int $sosa
84
+	 */
85
+	public function deleteAncestorsFrom(Tree $tree, User $user, int $sosa) : void
86
+	{
87
+		DB::table('maj_sosa')
88
+			->where('majs_gedcom_id', '=', $tree->id())
89
+			->where('majs_user_id', '=', $user->id())
90
+			->where('majs_sosa', '>=', $sosa)
91
+			->whereRaw(
92
+				'FLOOR(majs_sosa / (POW(2, (majs_gen - :gen)))) = :sosa',
93
+				['gen' => $this->generation($sosa), 'sosa' => $sosa])
94
+			->delete();
95
+	}
96 96
     
97
-    /**
98
-     * Insert (or update if already existing) a list of Sosa individuals
99
-     * 
100
-     * @param Tree $tree
101
-     * @param User $user
102
-     * @param array $sosa_records
103
-     */
104
-    public function insertOrUpdate(Tree $tree, User $user, array $sosa_records) {
105
-        $mass_update = DB::connection()->getDriverName() === 'mysql';
97
+	/**
98
+	 * Insert (or update if already existing) a list of Sosa individuals
99
+	 * 
100
+	 * @param Tree $tree
101
+	 * @param User $user
102
+	 * @param array $sosa_records
103
+	 */
104
+	public function insertOrUpdate(Tree $tree, User $user, array $sosa_records) {
105
+		$mass_update = DB::connection()->getDriverName() === 'mysql';
106 106
         
107
-        $bindings_placeholders = $bindings_values = [];
108
-        foreach($sosa_records as $i => $row) {
109
-            $gen = $this->generation($row['sosa']);
110
-            if($gen <=  self::MAX_DB_GENERATIONS) {
111
-                if($mass_update) {
112
-                    $bindings_placeholders[] = '(:tree_id'.$i.', :user_id'.$i.', :sosa'.$i.','.
113
-                        ' :indi_id'.$i.', :gen'.$i.', :byear'.$i.', :byearest'.$i.', :dyear'.$i.', :dyearest'.$i.')';
114
-                    $bindings_values = array_merge(
115
-                        $bindings_values,
116
-                        [
117
-                            'tree_id'.$i => $tree->id(),
118
-                            'user_id'.$i => $user->id(),
119
-                            'sosa'.$i => $row['sosa'],
120
-                            'indi_id'.$i => $row['indi'],
121
-                            'gen'.$i => $gen,
122
-                            'byear'.$i => $row['birth_year'],
123
-                            'byearest'.$i => $row['birth_year_est'],
124
-                            'dyear'.$i => $row['death_year'],
125
-                            'dyearest'.$i => $row['death_year_est']
126
-                        ]);
127
-                } else {
128
-                    DB::table('maj_sosa')->updateOrInsert(
129
-                        [ 'majs_gedcom_id' => $tree->id(), 'majs_user_id' => $user->id(), 'majs_sosa' => $row['sosa']],
130
-                        [
131
-                            'majs_i_id' => $row['indi'],
132
-                            'majs_gen' => $gen,
133
-                            'majs_birth_year' => $row['birth_year'],
134
-                            'majs_birth_year_est' => $row['birth_year_est'],
135
-                            'majs_death_year' => $row['death_year'],
136
-                            'majs_death_year_est' => $row['death_year_est']
137
-                        ]);
138
-                }
139
-            }
140
-        }
107
+		$bindings_placeholders = $bindings_values = [];
108
+		foreach($sosa_records as $i => $row) {
109
+			$gen = $this->generation($row['sosa']);
110
+			if($gen <=  self::MAX_DB_GENERATIONS) {
111
+				if($mass_update) {
112
+					$bindings_placeholders[] = '(:tree_id'.$i.', :user_id'.$i.', :sosa'.$i.','.
113
+						' :indi_id'.$i.', :gen'.$i.', :byear'.$i.', :byearest'.$i.', :dyear'.$i.', :dyearest'.$i.')';
114
+					$bindings_values = array_merge(
115
+						$bindings_values,
116
+						[
117
+							'tree_id'.$i => $tree->id(),
118
+							'user_id'.$i => $user->id(),
119
+							'sosa'.$i => $row['sosa'],
120
+							'indi_id'.$i => $row['indi'],
121
+							'gen'.$i => $gen,
122
+							'byear'.$i => $row['birth_year'],
123
+							'byearest'.$i => $row['birth_year_est'],
124
+							'dyear'.$i => $row['death_year'],
125
+							'dyearest'.$i => $row['death_year_est']
126
+						]);
127
+				} else {
128
+					DB::table('maj_sosa')->updateOrInsert(
129
+						[ 'majs_gedcom_id' => $tree->id(), 'majs_user_id' => $user->id(), 'majs_sosa' => $row['sosa']],
130
+						[
131
+							'majs_i_id' => $row['indi'],
132
+							'majs_gen' => $gen,
133
+							'majs_birth_year' => $row['birth_year'],
134
+							'majs_birth_year_est' => $row['birth_year_est'],
135
+							'majs_death_year' => $row['death_year'],
136
+							'majs_death_year_est' => $row['death_year_est']
137
+						]);
138
+				}
139
+			}
140
+		}
141 141
         
142
-        if($mass_update) {
143
-            DB::connection()->statement(
144
-                'INSERT INTO `' . DB::connection()->getTablePrefix() . 'maj_sosa`' .
145
-                ' (majs_gedcom_id, majs_user_id, majs_sosa,' .
146
-                '   majs_i_id, majs_gen, majs_birth_year, majs_birth_year_est, majs_death_year, majs_death_year_est)' .
147
-                ' VALUES ' . implode(',', $bindings_placeholders) .
148
-                ' ON DUPLICATE KEY UPDATE majs_i_id = VALUES(majs_i_id), majs_gen = VALUES(majs_gen),' .
149
-                '   majs_birth_year = VALUES(majs_birth_year), majs_birth_year_est = VALUES(majs_birth_year_est),' . 
150
-                '   majs_death_year = VALUES(majs_death_year), majs_death_year_est = VALUES(majs_death_year_est)',
151
-                $bindings_values);
152
-        }
153
-    }
142
+		if($mass_update) {
143
+			DB::connection()->statement(
144
+				'INSERT INTO `' . DB::connection()->getTablePrefix() . 'maj_sosa`' .
145
+				' (majs_gedcom_id, majs_user_id, majs_sosa,' .
146
+				'   majs_i_id, majs_gen, majs_birth_year, majs_birth_year_est, majs_death_year, majs_death_year_est)' .
147
+				' VALUES ' . implode(',', $bindings_placeholders) .
148
+				' ON DUPLICATE KEY UPDATE majs_i_id = VALUES(majs_i_id), majs_gen = VALUES(majs_gen),' .
149
+				'   majs_birth_year = VALUES(majs_birth_year), majs_birth_year_est = VALUES(majs_birth_year_est),' . 
150
+				'   majs_death_year = VALUES(majs_death_year), majs_death_year_est = VALUES(majs_death_year_est)',
151
+				$bindings_values);
152
+		}
153
+	}
154 154
     
155 155
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Services/SosaStatisticsService.php 1 patch
Indentation   +311 added lines, -311 removed lines patch added patch discarded remove patch
@@ -30,337 +30,337 @@
 block discarded – undo
30 30
 class SosaStatisticsService
31 31
 {
32 32
     
33
-    /**
34
-     * Reference user
35
-     * @var User $user
36
-     */
37
-    private $user;
33
+	/**
34
+	 * Reference user
35
+	 * @var User $user
36
+	 */
37
+	private $user;
38 38
     
39
-    /**
40
-     * Reference tree
41
-     * @var Tree $tree
42
-     */
43
-    private $tree;
39
+	/**
40
+	 * Reference tree
41
+	 * @var Tree $tree
42
+	 */
43
+	private $tree;
44 44
     
45
-    /**
46
-     * Constructor for Sosa Statistics Service
47
-     * 
48
-     * @param Tree $tree
49
-     * @param User $user
50
-     */
51
-    public function __construct(Tree $tree, User $user)
52
-    {
53
-        $this->tree = $tree;
54
-        $this->user = $user;
55
-    }
45
+	/**
46
+	 * Constructor for Sosa Statistics Service
47
+	 * 
48
+	 * @param Tree $tree
49
+	 * @param User $user
50
+	 */
51
+	public function __construct(Tree $tree, User $user)
52
+	{
53
+		$this->tree = $tree;
54
+		$this->user = $user;
55
+	}
56 56
     
57
-    /**
58
-     * Return the root individual for the reference tree and user.
59
-     * 
60
-     * @return Individual|NULL
61
-     */
62
-    public function rootIndividual() : ?Individual
63
-    {
64
-        $root_indi_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID');
65
-        return Registry::individualFactory()->make($root_indi_id, $this->tree);
66
-    }
57
+	/**
58
+	 * Return the root individual for the reference tree and user.
59
+	 * 
60
+	 * @return Individual|NULL
61
+	 */
62
+	public function rootIndividual() : ?Individual
63
+	{
64
+		$root_indi_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID');
65
+		return Registry::individualFactory()->make($root_indi_id, $this->tree);
66
+	}
67 67
     
68
-    /**
69
-     * Returns how many individuals exist in the tree.
70
-     *
71
-     * @return int
72
-     */
73
-    public function totalIndividuals(): int
74
-    {
75
-        return DB::table('individuals')
76
-            ->where('i_file', '=', $this->tree->id())
77
-            ->count();
78
-    }
68
+	/**
69
+	 * Returns how many individuals exist in the tree.
70
+	 *
71
+	 * @return int
72
+	 */
73
+	public function totalIndividuals(): int
74
+	{
75
+		return DB::table('individuals')
76
+			->where('i_file', '=', $this->tree->id())
77
+			->count();
78
+	}
79 79
     
80
-    /**
81
-     * Get the total count of Sosa ancestors for all generations
82
-     * 
83
-     * @return int
84
-     */
85
-    public function totalAncestors() : int
86
-    {
87
-        return DB::table('maj_sosa')
88
-            ->where('majs_gedcom_id', '=', $this->tree->id())
89
-            ->where('majs_user_id', '=', $this->user->id())
90
-            ->count();
91
-    }
80
+	/**
81
+	 * Get the total count of Sosa ancestors for all generations
82
+	 * 
83
+	 * @return int
84
+	 */
85
+	public function totalAncestors() : int
86
+	{
87
+		return DB::table('maj_sosa')
88
+			->where('majs_gedcom_id', '=', $this->tree->id())
89
+			->where('majs_user_id', '=', $this->user->id())
90
+			->count();
91
+	}
92 92
     
93
-    /**
94
-     * Get the total count of distinct Sosa ancestors for all generations
95
-     * 
96
-     * @return int
97
-     */
98
-    public function totalDistinctAncestors() : int
99
-    {
100
-        return DB::table('maj_sosa')
101
-        ->where('majs_gedcom_id', '=', $this->tree->id())
102
-        ->where('majs_user_id', '=', $this->user->id())
103
-        ->distinct()
104
-        ->count('majs_i_id');
105
-    }
93
+	/**
94
+	 * Get the total count of distinct Sosa ancestors for all generations
95
+	 * 
96
+	 * @return int
97
+	 */
98
+	public function totalDistinctAncestors() : int
99
+	{
100
+		return DB::table('maj_sosa')
101
+		->where('majs_gedcom_id', '=', $this->tree->id())
102
+		->where('majs_user_id', '=', $this->user->id())
103
+		->distinct()
104
+		->count('majs_i_id');
105
+	}
106 106
     
107
-    /**
108
-     * Get the mean generation time, as the slope of the linear regression of birth years vs generations
109
-     * 
110
-     * @return float
111
-     */
112
-    public function meanGenerationTime() : float
113
-    {
114
-        $row = DB::table('maj_sosa')
115
-            ->where('majs_gedcom_id', '=', $this->tree->id())
116
-            ->where('majs_user_id', '=', $this->user->id())
117
-            ->whereNotNull('majs_birth_year')
118
-            ->selectRaw('COUNT(majs_sosa) AS n')
119
-            ->selectRaw('SUM(majs_gen * majs_birth_year) AS sum_xy')
120
-            ->selectRaw('SUM(majs_gen) AS sum_x')
121
-            ->selectRaw('SUM(majs_birth_year) AS sum_y')
122
-            ->selectRaw('SUM(majs_gen * majs_gen) AS sum_x2')
123
-            ->get()->first();
107
+	/**
108
+	 * Get the mean generation time, as the slope of the linear regression of birth years vs generations
109
+	 * 
110
+	 * @return float
111
+	 */
112
+	public function meanGenerationTime() : float
113
+	{
114
+		$row = DB::table('maj_sosa')
115
+			->where('majs_gedcom_id', '=', $this->tree->id())
116
+			->where('majs_user_id', '=', $this->user->id())
117
+			->whereNotNull('majs_birth_year')
118
+			->selectRaw('COUNT(majs_sosa) AS n')
119
+			->selectRaw('SUM(majs_gen * majs_birth_year) AS sum_xy')
120
+			->selectRaw('SUM(majs_gen) AS sum_x')
121
+			->selectRaw('SUM(majs_birth_year) AS sum_y')
122
+			->selectRaw('SUM(majs_gen * majs_gen) AS sum_x2')
123
+			->get()->first();
124 124
         
125
-        return $row->n == 0 ? 0 :
126
-            -($row->n * $row->sum_xy - $row->sum_x * $row->sum_y) / ($row->n * $row->sum_x2 - pow($row->sum_x, 2));
127
-    }
125
+		return $row->n == 0 ? 0 :
126
+			-($row->n * $row->sum_xy - $row->sum_x * $row->sum_y) / ($row->n * $row->sum_x2 - pow($row->sum_x, 2));
127
+	}
128 128
     
129
-    /**
130
-     * Get the statistic array detailed by generation.
131
-     * Statistics for each generation are:
132
-     * 	- The number of Sosa in generation
133
-     * 	- The number of Sosa up to generation
134
-     *  - The number of distinct Sosa up to generation
135
-     *  - The year of the first birth in generation
136
-     *  - The year of the first estimated birth in generation
137
-     *  - The year of the last birth in generation
138
-     *  - The year of the last estimated birth in generation
139
-     *  - The average year of birth in generation
140
-     *
141
-     * @return array Statistics array
142
-     */
143
-    public function statisticsByGenerations() : array
144
-    {
145
-        $stats_by_gen = $this->statisticsByGenerationBasicData();
146
-        $cumul_stats_by_gen = $this->statisticsByGenerationCumulativeData();
129
+	/**
130
+	 * Get the statistic array detailed by generation.
131
+	 * Statistics for each generation are:
132
+	 * 	- The number of Sosa in generation
133
+	 * 	- The number of Sosa up to generation
134
+	 *  - The number of distinct Sosa up to generation
135
+	 *  - The year of the first birth in generation
136
+	 *  - The year of the first estimated birth in generation
137
+	 *  - The year of the last birth in generation
138
+	 *  - The year of the last estimated birth in generation
139
+	 *  - The average year of birth in generation
140
+	 *
141
+	 * @return array Statistics array
142
+	 */
143
+	public function statisticsByGenerations() : array
144
+	{
145
+		$stats_by_gen = $this->statisticsByGenerationBasicData();
146
+		$cumul_stats_by_gen = $this->statisticsByGenerationCumulativeData();
147 147
         
148
-        $statistics_by_gen = [];
149
-        foreach($stats_by_gen as $gen => $stats_gen) {
150
-            $statistics_by_gen[(int) $stats_gen->gen] = array(
151
-                'sosaCount'				=>	(int) $stats_gen->total_sosa,
152
-                'sosaTotalCount'		=>	(int) $cumul_stats_by_gen[$gen]->total_cumul,
153
-                'diffSosaTotalCount'	=>	(int) $cumul_stats_by_gen[$gen]->total_distinct_cumul,
154
-                'firstBirth'			=>	$stats_gen->first_year,
155
-                'firstEstimatedBirth'	=>	$stats_gen->first_est_year,
156
-                'lastBirth'				=>	$stats_gen->last_year,
157
-                'lastEstimatedBirth'	=>	$stats_gen->last_est_year
158
-            );
159
-        }
148
+		$statistics_by_gen = [];
149
+		foreach($stats_by_gen as $gen => $stats_gen) {
150
+			$statistics_by_gen[(int) $stats_gen->gen] = array(
151
+				'sosaCount'				=>	(int) $stats_gen->total_sosa,
152
+				'sosaTotalCount'		=>	(int) $cumul_stats_by_gen[$gen]->total_cumul,
153
+				'diffSosaTotalCount'	=>	(int) $cumul_stats_by_gen[$gen]->total_distinct_cumul,
154
+				'firstBirth'			=>	$stats_gen->first_year,
155
+				'firstEstimatedBirth'	=>	$stats_gen->first_est_year,
156
+				'lastBirth'				=>	$stats_gen->last_year,
157
+				'lastEstimatedBirth'	=>	$stats_gen->last_est_year
158
+			);
159
+		}
160 160
         
161
-        return $statistics_by_gen;
162
-    }
161
+		return $statistics_by_gen;
162
+	}
163 163
     
164
-    /**
165
-     * Returns the basic statistics data by generation.
166
-     * 
167
-     * @return Collection
168
-     */
169
-    private function statisticsByGenerationBasicData() : Collection
170
-    {
171
-        return DB::table('maj_sosa')
172
-            ->where('majs_gedcom_id', '=', $this->tree->id())
173
-            ->where('majs_user_id', '=', $this->user->id())
174
-            ->groupBy('majs_gen')
175
-            ->orderBy('majs_gen', 'asc')
176
-            ->select('majs_gen AS gen')
177
-            ->selectRaw('COUNT(majs_sosa) AS total_sosa')
178
-            ->selectRaw('MIN(majs_birth_year) AS first_year')
179
-            ->selectRaw('MIN(majs_birth_year_est) AS first_est_year')
180
-            ->selectRaw('MAX(majs_birth_year) AS last_year')
181
-            ->selectRaw('MAX(majs_birth_year_est) AS last_est_year')
182
-            ->get()->keyBy('gen');
183
-    }
164
+	/**
165
+	 * Returns the basic statistics data by generation.
166
+	 * 
167
+	 * @return Collection
168
+	 */
169
+	private function statisticsByGenerationBasicData() : Collection
170
+	{
171
+		return DB::table('maj_sosa')
172
+			->where('majs_gedcom_id', '=', $this->tree->id())
173
+			->where('majs_user_id', '=', $this->user->id())
174
+			->groupBy('majs_gen')
175
+			->orderBy('majs_gen', 'asc')
176
+			->select('majs_gen AS gen')
177
+			->selectRaw('COUNT(majs_sosa) AS total_sosa')
178
+			->selectRaw('MIN(majs_birth_year) AS first_year')
179
+			->selectRaw('MIN(majs_birth_year_est) AS first_est_year')
180
+			->selectRaw('MAX(majs_birth_year) AS last_year')
181
+			->selectRaw('MAX(majs_birth_year_est) AS last_est_year')
182
+			->get()->keyBy('gen');
183
+	}
184 184
     
185
-    /**
186
-     * Returns the cumulative statistics data by generation
187
-     * 
188
-     * @return Collection
189
-     */
190
-    private function statisticsByGenerationCumulativeData() : Collection
191
-    {
192
-        $list_gen = DB::table('maj_sosa')->select('majs_gen')->distinct()
193
-            ->where('majs_gedcom_id', '=', $this->tree->id())
194
-            ->where('majs_user_id', '=', $this->user->id());
185
+	/**
186
+	 * Returns the cumulative statistics data by generation
187
+	 * 
188
+	 * @return Collection
189
+	 */
190
+	private function statisticsByGenerationCumulativeData() : Collection
191
+	{
192
+		$list_gen = DB::table('maj_sosa')->select('majs_gen')->distinct()
193
+			->where('majs_gedcom_id', '=', $this->tree->id())
194
+			->where('majs_user_id', '=', $this->user->id());
195 195
         
196
-        return DB::table('maj_sosa')
197
-            ->joinSub($list_gen, 'list_gen', function(JoinClause $join) : void {
198
-                $join->on('maj_sosa.majs_gen', '<=', 'list_gen.majs_gen')
199
-                ->where('majs_gedcom_id', '=', $this->tree->id())
200
-                ->where('majs_user_id', '=', $this->user->id());
201
-            })
202
-            ->groupBy('list_gen.majs_gen')
203
-            ->select('list_gen.majs_gen AS gen')
204
-            ->selectRaw('COUNT(majs_i_id) AS total_cumul')
205
-            ->selectRaw('COUNT(DISTINCT majs_i_id) AS total_distinct_cumul')
206
-            ->get()->keyBy('gen');
207
-    }
196
+		return DB::table('maj_sosa')
197
+			->joinSub($list_gen, 'list_gen', function(JoinClause $join) : void {
198
+				$join->on('maj_sosa.majs_gen', '<=', 'list_gen.majs_gen')
199
+				->where('majs_gedcom_id', '=', $this->tree->id())
200
+				->where('majs_user_id', '=', $this->user->id());
201
+			})
202
+			->groupBy('list_gen.majs_gen')
203
+			->select('list_gen.majs_gen AS gen')
204
+			->selectRaw('COUNT(majs_i_id) AS total_cumul')
205
+			->selectRaw('COUNT(DISTINCT majs_i_id) AS total_distinct_cumul')
206
+			->get()->keyBy('gen');
207
+	}
208 208
     
209
-    /**
210
-     * Return a Collection of the mean generation depth and standard deviation for all Sosa ancestors at a given generation.
211
-     * Sosa 1 is of generation 1.
212
-     *
213
-     * Mean generation depth and deviation are calculated based on the works of Marie-Héléne Cazes and Pierre Cazes,
214
-     * published in Population (French Edition), Vol. 51, No. 1 (Jan. - Feb., 1996), pp. 117-140
215
-     * http://kintip.net/index.php?option=com_jdownloads&task=download.send&id=9&catid=4&m=0
216
-     *
217
-     * Format:
218
-     *  - key : sosa number of the ancestor
219
-     *  - values: 
220
-     *      - root_ancestor_id : ID of the ancestor
221
-     *      - mean_gen_depth : Mean generation depth
222
-     *      - stddev_gen_depth : Standard deviation of generation depth
223
-     *
224
-     * @param int $gen Sosa generation
225
-     * @return Collection
226
-     */
227
-    public function generationDepthStatsAtGeneration(int $gen) : Collection
228
-    {
229
-        $table_prefix = DB::connection()->getTablePrefix();
230
-        $missing_ancestors_by_gen = DB::table('maj_sosa AS sosa')
231
-            ->selectRaw($table_prefix. 'sosa.majs_gen - ? AS majs_gen_norm', [$gen])
232
-            ->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])
233
-            ->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')
234
-            ->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')
235
-            ->leftJoin('maj_sosa AS sosa_fat', function(JoinClause $join) use ($table_prefix) : void {    // Link to sosa's father
236
-                $join->whereRaw($table_prefix . 'sosa_fat.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa')
237
-                ->where('sosa_fat.majs_gedcom_id', '=', $this->tree->id())
238
-                ->where('sosa_fat.majs_user_id', '=', $this->user->id());
239
-            })
240
-            ->leftJoin('maj_sosa AS sosa_mot', function(JoinClause $join) use ($table_prefix) : void {    // Link to sosa's mother
241
-                $join->whereRaw($table_prefix . 'sosa_mot.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa + 1')
242
-                ->where('sosa_mot.majs_gedcom_id', '=', $this->tree->id())
243
-                ->where('sosa_mot.majs_user_id', '=', $this->user->id());
244
-            })
245
-            ->where('sosa.majs_gedcom_id', '=', $this->tree->id())
246
-            ->where('sosa.majs_user_id', '=', $this->user->id())
247
-            ->where('sosa.majs_gen', '>=', $gen)
248
-            ->where(function(Builder $query) : void {
249
-                $query->whereNull('sosa_fat.majs_i_id')
250
-                    ->orWhereNull('sosa_mot.majs_i_id');
251
-            })
252
-            ->groupBy(['sosa.majs_gen', 'root_ancestor']);
209
+	/**
210
+	 * Return a Collection of the mean generation depth and standard deviation for all Sosa ancestors at a given generation.
211
+	 * Sosa 1 is of generation 1.
212
+	 *
213
+	 * Mean generation depth and deviation are calculated based on the works of Marie-Héléne Cazes and Pierre Cazes,
214
+	 * published in Population (French Edition), Vol. 51, No. 1 (Jan. - Feb., 1996), pp. 117-140
215
+	 * http://kintip.net/index.php?option=com_jdownloads&task=download.send&id=9&catid=4&m=0
216
+	 *
217
+	 * Format:
218
+	 *  - key : sosa number of the ancestor
219
+	 *  - values: 
220
+	 *      - root_ancestor_id : ID of the ancestor
221
+	 *      - mean_gen_depth : Mean generation depth
222
+	 *      - stddev_gen_depth : Standard deviation of generation depth
223
+	 *
224
+	 * @param int $gen Sosa generation
225
+	 * @return Collection
226
+	 */
227
+	public function generationDepthStatsAtGeneration(int $gen) : Collection
228
+	{
229
+		$table_prefix = DB::connection()->getTablePrefix();
230
+		$missing_ancestors_by_gen = DB::table('maj_sosa AS sosa')
231
+			->selectRaw($table_prefix. 'sosa.majs_gen - ? AS majs_gen_norm', [$gen])
232
+			->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])
233
+			->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')
234
+			->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')
235
+			->leftJoin('maj_sosa AS sosa_fat', function(JoinClause $join) use ($table_prefix) : void {    // Link to sosa's father
236
+				$join->whereRaw($table_prefix . 'sosa_fat.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa')
237
+				->where('sosa_fat.majs_gedcom_id', '=', $this->tree->id())
238
+				->where('sosa_fat.majs_user_id', '=', $this->user->id());
239
+			})
240
+			->leftJoin('maj_sosa AS sosa_mot', function(JoinClause $join) use ($table_prefix) : void {    // Link to sosa's mother
241
+				$join->whereRaw($table_prefix . 'sosa_mot.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa + 1')
242
+				->where('sosa_mot.majs_gedcom_id', '=', $this->tree->id())
243
+				->where('sosa_mot.majs_user_id', '=', $this->user->id());
244
+			})
245
+			->where('sosa.majs_gedcom_id', '=', $this->tree->id())
246
+			->where('sosa.majs_user_id', '=', $this->user->id())
247
+			->where('sosa.majs_gen', '>=', $gen)
248
+			->where(function(Builder $query) : void {
249
+				$query->whereNull('sosa_fat.majs_i_id')
250
+					->orWhereNull('sosa_mot.majs_i_id');
251
+			})
252
+			->groupBy(['sosa.majs_gen', 'root_ancestor']);
253 253
 
254
-        return DB::table('maj_sosa AS sosa_list')
255
-            ->select(['stats_by_gen.root_ancestor AS root_ancestor_sosa', 'sosa_list.majs_i_id as root_ancestor_id'])
256
-            ->selectRaw('1 + SUM( (majs_gen_norm) * ( 2 * full_root_count + semi_root_count) /  (2 * POWER(2, majs_gen_norm))) AS mean_gen_depth')
257
-            ->selectRaw(' SQRT('.
258
-                '   SUM(POWER(majs_gen_norm, 2) * ( 2 * full_root_count + semi_root_count) /  (2 * POWER(2, majs_gen_norm)))'.
259
-                '   - POWER( SUM( (majs_gen_norm) * ( 2 * full_root_count + semi_root_count) /  (2 * POWER(2, majs_gen_norm))), 2)'.
260
-                ' ) AS stddev_gen_depth')
261
-            ->joinSub($missing_ancestors_by_gen, 'stats_by_gen', function(JoinClause $join) : void {
262
-                $join->on('sosa_list.majs_sosa', '=', 'stats_by_gen.root_ancestor')
263
-                    ->where('sosa_list.majs_gedcom_id', '=', $this->tree->id())
264
-                    ->where('sosa_list.majs_user_id', '=', $this->user->id());
265
-            })
266
-            ->groupBy(['stats_by_gen.root_ancestor', 'sosa_list.majs_i_id'])
267
-            ->orderBy('stats_by_gen.root_ancestor')
268
-            ->get()->keyBy('root_ancestor_sosa');
269
-    }
254
+		return DB::table('maj_sosa AS sosa_list')
255
+			->select(['stats_by_gen.root_ancestor AS root_ancestor_sosa', 'sosa_list.majs_i_id as root_ancestor_id'])
256
+			->selectRaw('1 + SUM( (majs_gen_norm) * ( 2 * full_root_count + semi_root_count) /  (2 * POWER(2, majs_gen_norm))) AS mean_gen_depth')
257
+			->selectRaw(' SQRT('.
258
+				'   SUM(POWER(majs_gen_norm, 2) * ( 2 * full_root_count + semi_root_count) /  (2 * POWER(2, majs_gen_norm)))'.
259
+				'   - POWER( SUM( (majs_gen_norm) * ( 2 * full_root_count + semi_root_count) /  (2 * POWER(2, majs_gen_norm))), 2)'.
260
+				' ) AS stddev_gen_depth')
261
+			->joinSub($missing_ancestors_by_gen, 'stats_by_gen', function(JoinClause $join) : void {
262
+				$join->on('sosa_list.majs_sosa', '=', 'stats_by_gen.root_ancestor')
263
+					->where('sosa_list.majs_gedcom_id', '=', $this->tree->id())
264
+					->where('sosa_list.majs_user_id', '=', $this->user->id());
265
+			})
266
+			->groupBy(['stats_by_gen.root_ancestor', 'sosa_list.majs_i_id'])
267
+			->orderBy('stats_by_gen.root_ancestor')
268
+			->get()->keyBy('root_ancestor_sosa');
269
+	}
270 270
     
271
-    /**
272
-     * Return a collection of the most duplicated root Sosa ancestors.
273
-     * The number of ancestors to return is limited by the parameter $limit.
274
-     * If several individuals are tied when reaching the limit, none of them are returned,
275
-     * which means that there can be less individuals returned than requested.
276
-     *
277
-     * Format:
278
-     *  - value:
279
-     *      - sosa_i_id : sosa individual
280
-     *      - sosa_count: number of duplications of the ancestor (e.g. 3 if it appears 3 times)
281
-     *
282
-     * @param int $limit
283
-     * @return Collection
284
-     */
285
-    public function topMultipleAncestorsWithNoTies(int $limit) : Collection
286
-    {
287
-        $table_prefix = DB::connection()->getTablePrefix();
288
-        $multiple_ancestors = DB::table('maj_sosa AS sosa')
289
-            ->select('sosa.majs_i_id AS sosa_i_id')
290
-            ->selectRaw('COUNT('. $table_prefix .'sosa.majs_sosa) AS sosa_count')
291
-            ->leftJoin('maj_sosa AS sosa_fat', function(JoinClause $join) use ($table_prefix) : void {    // Link to sosa's father
292
-                $join->whereRaw($table_prefix . 'sosa_fat.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa')
293
-                    ->where('sosa_fat.majs_gedcom_id', '=', $this->tree->id())
294
-                    ->where('sosa_fat.majs_user_id', '=', $this->user->id());
295
-            })
296
-            ->leftJoin('maj_sosa AS sosa_mot', function(JoinClause $join) use ($table_prefix) : void {    // Link to sosa's mother
297
-                $join->whereRaw($table_prefix . 'sosa_mot.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa + 1')
298
-                ->where('sosa_mot.majs_gedcom_id', '=', $this->tree->id())
299
-                ->where('sosa_mot.majs_user_id', '=', $this->user->id());
300
-            })
301
-            ->where('sosa.majs_gedcom_id', '=', $this->tree->id())
302
-            ->where('sosa.majs_user_id', '=', $this->user->id())
303
-            ->whereNull('sosa_fat.majs_sosa')   // We keep only root individuals, i.e. those with no father or mother
304
-            ->whereNull('sosa_mot.majs_sosa')
305
-            ->groupBy('sosa.majs_i_id')
306
-            ->havingRaw('COUNT('. $table_prefix .'sosa.majs_sosa) > 1')    // Limit to the duplicate sosas.
307
-            ->orderByRaw('COUNT('. $table_prefix .'sosa.majs_sosa) DESC, MIN('. $table_prefix .'sosa.majs_sosa) ASC')
308
-            ->limit($limit + 1)     // We want to select one more than required, for ties
309
-            ->get();
271
+	/**
272
+	 * Return a collection of the most duplicated root Sosa ancestors.
273
+	 * The number of ancestors to return is limited by the parameter $limit.
274
+	 * If several individuals are tied when reaching the limit, none of them are returned,
275
+	 * which means that there can be less individuals returned than requested.
276
+	 *
277
+	 * Format:
278
+	 *  - value:
279
+	 *      - sosa_i_id : sosa individual
280
+	 *      - sosa_count: number of duplications of the ancestor (e.g. 3 if it appears 3 times)
281
+	 *
282
+	 * @param int $limit
283
+	 * @return Collection
284
+	 */
285
+	public function topMultipleAncestorsWithNoTies(int $limit) : Collection
286
+	{
287
+		$table_prefix = DB::connection()->getTablePrefix();
288
+		$multiple_ancestors = DB::table('maj_sosa AS sosa')
289
+			->select('sosa.majs_i_id AS sosa_i_id')
290
+			->selectRaw('COUNT('. $table_prefix .'sosa.majs_sosa) AS sosa_count')
291
+			->leftJoin('maj_sosa AS sosa_fat', function(JoinClause $join) use ($table_prefix) : void {    // Link to sosa's father
292
+				$join->whereRaw($table_prefix . 'sosa_fat.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa')
293
+					->where('sosa_fat.majs_gedcom_id', '=', $this->tree->id())
294
+					->where('sosa_fat.majs_user_id', '=', $this->user->id());
295
+			})
296
+			->leftJoin('maj_sosa AS sosa_mot', function(JoinClause $join) use ($table_prefix) : void {    // Link to sosa's mother
297
+				$join->whereRaw($table_prefix . 'sosa_mot.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa + 1')
298
+				->where('sosa_mot.majs_gedcom_id', '=', $this->tree->id())
299
+				->where('sosa_mot.majs_user_id', '=', $this->user->id());
300
+			})
301
+			->where('sosa.majs_gedcom_id', '=', $this->tree->id())
302
+			->where('sosa.majs_user_id', '=', $this->user->id())
303
+			->whereNull('sosa_fat.majs_sosa')   // We keep only root individuals, i.e. those with no father or mother
304
+			->whereNull('sosa_mot.majs_sosa')
305
+			->groupBy('sosa.majs_i_id')
306
+			->havingRaw('COUNT('. $table_prefix .'sosa.majs_sosa) > 1')    // Limit to the duplicate sosas.
307
+			->orderByRaw('COUNT('. $table_prefix .'sosa.majs_sosa) DESC, MIN('. $table_prefix .'sosa.majs_sosa) ASC')
308
+			->limit($limit + 1)     // We want to select one more than required, for ties
309
+			->get();
310 310
             
311
-        if($multiple_ancestors->count() > $limit)
312
-        {
313
-            $last_count = $multiple_ancestors->last()->sosa_count;
314
-            $multiple_ancestors = $multiple_ancestors->reject(function($element) use ($last_count) : bool {
315
-                return $element->sosa_count ==  $last_count;
316
-            });
317
-        }
318
-        return $multiple_ancestors;
319
-    }
311
+		if($multiple_ancestors->count() > $limit)
312
+		{
313
+			$last_count = $multiple_ancestors->last()->sosa_count;
314
+			$multiple_ancestors = $multiple_ancestors->reject(function($element) use ($last_count) : bool {
315
+				return $element->sosa_count ==  $last_count;
316
+			});
317
+		}
318
+		return $multiple_ancestors;
319
+	}
320 320
     
321
-    /**
322
-     * Return a computed array of statistics about the dispersion of ancestors across the ancestors
323
-     * at a specified generation.
324
-     * 
325
-     * Format: 
326
-     *  - key : rank of the ancestor in generation G for which exclusive ancestors have been found
327
-     *          For instance 3 represent the maternal grand father
328
-     *          0 is used for shared ancestors
329
-     *  - values: number of ancestors exclusively in the ancestors of the ancestor in key
330
-     *  
331
-     *  For instance a result at generation 3 could be :
332
-     *      array (   0     =>  12      -> 12 ancestors are shared by the grand-parents
333
-     *                1     =>  32      -> 32 ancestors are exclusive to the paternal grand-father
334
-     *                2     =>  25      -> 25 ancestors are exclusive to the paternal grand-mother
335
-     *                3     =>  12      -> 12 ancestors are exclusive to the maternal grand-father
336
-     *                4     =>  30      -> 30 ancestors are exclusive to the maternal grand-mother
337
-     *            )
338
-     * 
339
-     * @param int $gen
340
-     * @return Collection
341
-     */
342
-    public function ancestorsDispersionForGeneration(int $gen) : Collection
343
-    {
344
-        $ancestors_branches = DB::table('maj_sosa')
345
-            ->select('majs_i_id AS i_id')
346
-            ->selectRaw('FLOOR(majs_sosa / POW(2, (majs_gen - ?))) - POW(2, ? -1) + 1 AS branch', [$gen, $gen])
347
-            ->where('majs_gedcom_id', '=', $this->tree->id())
348
-            ->where('majs_user_id', '=', $this->user->id())
349
-            ->where('majs_gen', '>=', $gen)
350
-            ->groupBy('majs_i_id', 'branch');
321
+	/**
322
+	 * Return a computed array of statistics about the dispersion of ancestors across the ancestors
323
+	 * at a specified generation.
324
+	 * 
325
+	 * Format: 
326
+	 *  - key : rank of the ancestor in generation G for which exclusive ancestors have been found
327
+	 *          For instance 3 represent the maternal grand father
328
+	 *          0 is used for shared ancestors
329
+	 *  - values: number of ancestors exclusively in the ancestors of the ancestor in key
330
+	 *  
331
+	 *  For instance a result at generation 3 could be :
332
+	 *      array (   0     =>  12      -> 12 ancestors are shared by the grand-parents
333
+	 *                1     =>  32      -> 32 ancestors are exclusive to the paternal grand-father
334
+	 *                2     =>  25      -> 25 ancestors are exclusive to the paternal grand-mother
335
+	 *                3     =>  12      -> 12 ancestors are exclusive to the maternal grand-father
336
+	 *                4     =>  30      -> 30 ancestors are exclusive to the maternal grand-mother
337
+	 *            )
338
+	 * 
339
+	 * @param int $gen
340
+	 * @return Collection
341
+	 */
342
+	public function ancestorsDispersionForGeneration(int $gen) : Collection
343
+	{
344
+		$ancestors_branches = DB::table('maj_sosa')
345
+			->select('majs_i_id AS i_id')
346
+			->selectRaw('FLOOR(majs_sosa / POW(2, (majs_gen - ?))) - POW(2, ? -1) + 1 AS branch', [$gen, $gen])
347
+			->where('majs_gedcom_id', '=', $this->tree->id())
348
+			->where('majs_user_id', '=', $this->user->id())
349
+			->where('majs_gen', '>=', $gen)
350
+			->groupBy('majs_i_id', 'branch');
351 351
         
352 352
             
353
-        $consolidated_ancestors_branches = DB::table('maj_sosa')
354
-            ->fromSub($ancestors_branches, 'indi_branch')
355
-            ->select('i_id')
356
-            ->selectRaw('CASE WHEN COUNT(branch) > 1 THEN 0 ELSE MIN(branch) END AS branches')
357
-            ->groupBy('i_id');
353
+		$consolidated_ancestors_branches = DB::table('maj_sosa')
354
+			->fromSub($ancestors_branches, 'indi_branch')
355
+			->select('i_id')
356
+			->selectRaw('CASE WHEN COUNT(branch) > 1 THEN 0 ELSE MIN(branch) END AS branches')
357
+			->groupBy('i_id');
358 358
             
359
-        return DB::table('maj_sosa')
360
-            ->fromSub($consolidated_ancestors_branches, 'indi_branch_consolidated')
361
-            ->select('branches')
362
-            ->selectRaw('COUNT(i_id) AS count_indi')
363
-            ->groupBy('branches')
364
-            ->get()->pluck('count_indi', 'branches');
365
-    }
359
+		return DB::table('maj_sosa')
360
+			->fromSub($consolidated_ancestors_branches, 'indi_branch_consolidated')
361
+			->select('branches')
362
+			->selectRaw('COUNT(i_id) AS count_indi')
363
+			->groupBy('branches')
364
+			->get()->pluck('count_indi', 'branches');
365
+	}
366 366
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Services/SosaCalculatorService.php 1 patch
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -25,126 +25,126 @@
 block discarded – undo
25 25
  */
26 26
 class SosaCalculatorService
27 27
 {
28
-    /**
29
-     * Maximium size for the temporary Sosa table
30
-     * @var int TMP_SOSA_TABLE_LIMIT
31
-     */
32
-    private const TMP_SOSA_TABLE_LIMIT = 1000;
28
+	/**
29
+	 * Maximium size for the temporary Sosa table
30
+	 * @var int TMP_SOSA_TABLE_LIMIT
31
+	 */
32
+	private const TMP_SOSA_TABLE_LIMIT = 1000;
33 33
     
34
-    /**
35
-     * @var SosaRecordsService $sosa_records_service
36
-     */
37
-    private $sosa_records_service;
34
+	/**
35
+	 * @var SosaRecordsService $sosa_records_service
36
+	 */
37
+	private $sosa_records_service;
38 38
     
39
-    /**
40
-     * Reference user
41
-     * @var User $user
42
-     */
43
-    private $user;
39
+	/**
40
+	 * Reference user
41
+	 * @var User $user
42
+	 */
43
+	private $user;
44 44
     
45
-    /**
46
-     * Reference tree
47
-     * @var Tree $tree
48
-     */
49
-    private $tree;
45
+	/**
46
+	 * Reference tree
47
+	 * @var Tree $tree
48
+	 */
49
+	private $tree;
50 50
     
51
-    /**
52
-     * Temporary Sosa table, used during construction
53
-     * @var array<string,mixed> $tmp_sosa_table
54
-     */
55
-    private $tmp_sosa_table;
51
+	/**
52
+	 * Temporary Sosa table, used during construction
53
+	 * @var array<string,mixed> $tmp_sosa_table
54
+	 */
55
+	private $tmp_sosa_table;
56 56
     
57
-    /**
58
-     * Constructor for the Sosa Calculator
59
-     * 
60
-     * @param SosaRecordsService $sosa_records_service
61
-     * @param Tree $tree
62
-     * @param User $user
63
-     */
64
-    public function __construct(SosaRecordsService $sosa_records_service, Tree $tree, User $user)
65
-    {
66
-        $this->sosa_records_service = $sosa_records_service;
67
-        $this->tree = $tree;
68
-        $this->user = $user;
69
-        $this->tmp_sosa_table = array();
70
-    }
57
+	/**
58
+	 * Constructor for the Sosa Calculator
59
+	 * 
60
+	 * @param SosaRecordsService $sosa_records_service
61
+	 * @param Tree $tree
62
+	 * @param User $user
63
+	 */
64
+	public function __construct(SosaRecordsService $sosa_records_service, Tree $tree, User $user)
65
+	{
66
+		$this->sosa_records_service = $sosa_records_service;
67
+		$this->tree = $tree;
68
+		$this->user = $user;
69
+		$this->tmp_sosa_table = array();
70
+	}
71 71
     
72
-    /**
73
-     * Compute all Sosa ancestors from the user's root individual.
74
-     * 
75
-     * @return bool Result of the computation
76
-     */
77
-    public function computeAll(): bool
78
-    {
79
-        $root_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID');
80
-        if($indi = Registry::individualFactory()->make($root_id, $this->tree)) {
81
-            $this->sosa_records_service->deleteAll($this->tree, $this->user);
82
-            $this->addNode($indi, 1);
83
-            $this->flushTmpSosaTable(true);
84
-            return true;
85
-        }
86
-        return false;
87
-    }
72
+	/**
73
+	 * Compute all Sosa ancestors from the user's root individual.
74
+	 * 
75
+	 * @return bool Result of the computation
76
+	 */
77
+	public function computeAll(): bool
78
+	{
79
+		$root_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID');
80
+		if($indi = Registry::individualFactory()->make($root_id, $this->tree)) {
81
+			$this->sosa_records_service->deleteAll($this->tree, $this->user);
82
+			$this->addNode($indi, 1);
83
+			$this->flushTmpSosaTable(true);
84
+			return true;
85
+		}
86
+		return false;
87
+	}
88 88
     
89
-    /**
90
-     * Compute all Sosa Ancestors from a specified Individual
91
-     * 
92
-     * @param Individual $indi
93
-     * @return bool
94
-     */
95
-    public function computeFromIndividual(Individual $indi) : bool
96
-    {
97
-        $current_sosas = $this->sosa_records_service->getSosaNumbers($indi);
98
-        foreach(array_keys($current_sosas) as $sosa) {
99
-            $this->sosa_records_service->deleteAncestorsFrom($this->tree, $this->user, $sosa);
100
-            $this->addNode($indi, $sosa);
101
-        }
102
-        $this->flushTmpSosaTable(true);
103
-        return true;
104
-    }
89
+	/**
90
+	 * Compute all Sosa Ancestors from a specified Individual
91
+	 * 
92
+	 * @param Individual $indi
93
+	 * @return bool
94
+	 */
95
+	public function computeFromIndividual(Individual $indi) : bool
96
+	{
97
+		$current_sosas = $this->sosa_records_service->getSosaNumbers($indi);
98
+		foreach(array_keys($current_sosas) as $sosa) {
99
+			$this->sosa_records_service->deleteAncestorsFrom($this->tree, $this->user, $sosa);
100
+			$this->addNode($indi, $sosa);
101
+		}
102
+		$this->flushTmpSosaTable(true);
103
+		return true;
104
+	}
105 105
     
106
-    /**
107
-     * Recursive method to add individual to the Sosa table, and flush it regularly
108
-     * 
109
-     * @param Individual $indi Individual to add
110
-     * @param int $sosa Individual's sosa
111
-     */
112
-    private function addNode(Individual $indi, int $sosa) : void
113
-    {
114
-        $birth_year = $indi->getBirthDate()->gregorianYear();
115
-        $birth_year_est = $birth_year === 0 ? $indi->getEstimatedBirthDate()->gregorianYear() : $birth_year;
106
+	/**
107
+	 * Recursive method to add individual to the Sosa table, and flush it regularly
108
+	 * 
109
+	 * @param Individual $indi Individual to add
110
+	 * @param int $sosa Individual's sosa
111
+	 */
112
+	private function addNode(Individual $indi, int $sosa) : void
113
+	{
114
+		$birth_year = $indi->getBirthDate()->gregorianYear();
115
+		$birth_year_est = $birth_year === 0 ? $indi->getEstimatedBirthDate()->gregorianYear() : $birth_year;
116 116
         
117
-        $death_year = $indi->getDeathDate()->gregorianYear();
118
-        $death_year_est = $death_year === 0 ? $indi->getEstimatedDeathDate()->gregorianYear() : $death_year;
117
+		$death_year = $indi->getDeathDate()->gregorianYear();
118
+		$death_year_est = $death_year === 0 ? $indi->getEstimatedDeathDate()->gregorianYear() : $death_year;
119 119
         
120
-        $this->tmp_sosa_table[] = array(
121
-            'indi' => $indi->xref(),
122
-            'sosa' => $sosa,
123
-            'birth_year' => $birth_year === 0 ? null : $birth_year,
124
-            'birth_year_est' => $birth_year_est === 0 ? null : $birth_year_est,
125
-            'death_year' => $death_year === 0 ? null : $death_year,
126
-            'death_year_est' => $death_year_est === 0 ? null : $death_year_est
127
-        );
120
+		$this->tmp_sosa_table[] = array(
121
+			'indi' => $indi->xref(),
122
+			'sosa' => $sosa,
123
+			'birth_year' => $birth_year === 0 ? null : $birth_year,
124
+			'birth_year_est' => $birth_year_est === 0 ? null : $birth_year_est,
125
+			'death_year' => $death_year === 0 ? null : $death_year,
126
+			'death_year_est' => $death_year_est === 0 ? null : $death_year_est
127
+		);
128 128
         
129
-        $this->flushTmpSosaTable();
129
+		$this->flushTmpSosaTable();
130 130
         
131
-        if(($fam = $indi->childFamilies()->first()) !== null) {
132
-            /** @var \Fisharebest\Webtrees\Family $fam */
133
-            if($husb = $fam->husband()) $this->addNode($husb, 2 * $sosa);
134
-            if($wife = $fam->wife()) $this->addNode($wife, 2 * $sosa + 1);
135
-        }
136
-    }
131
+		if(($fam = $indi->childFamilies()->first()) !== null) {
132
+			/** @var \Fisharebest\Webtrees\Family $fam */
133
+			if($husb = $fam->husband()) $this->addNode($husb, 2 * $sosa);
134
+			if($wife = $fam->wife()) $this->addNode($wife, 2 * $sosa + 1);
135
+		}
136
+	}
137 137
     
138
-    /**
139
-     * Write sosas in the table, if the number of items is superior to the limit, or if forced.
140
-     *
141
-     * @param bool $force Should the flush be forced
142
-     */
143
-    private function flushTmpSosaTable($force = false) {
144
-        if( count($this->tmp_sosa_table)> 0 &&
145
-            ($force ||  count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)){
146
-                $this->sosa_records_service->insertOrUpdate($this->tree, $this->user, $this->tmp_sosa_table);
147
-                $this->tmp_sosa_table = array();
148
-        }
149
-    }
138
+	/**
139
+	 * Write sosas in the table, if the number of items is superior to the limit, or if forced.
140
+	 *
141
+	 * @param bool $force Should the flush be forced
142
+	 */
143
+	private function flushTmpSosaTable($force = false) {
144
+		if( count($this->tmp_sosa_table)> 0 &&
145
+			($force ||  count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)){
146
+				$this->sosa_records_service->insertOrUpdate($this->tree, $this->user, $this->tmp_sosa_table);
147
+				$this->tmp_sosa_table = array();
148
+		}
149
+	}
150 150
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/SosaModule.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -37,122 +37,122 @@
 block discarded – undo
37 37
  */
38 38
 class SosaModule extends AbstractModuleMaj implements ModuleMenuInterface, ModuleGlobalInterface
39 39
 {
40
-    use ModuleMenuTrait;
41
-    use ModuleGlobalTrait;
40
+	use ModuleMenuTrait;
41
+	use ModuleGlobalTrait;
42 42
     
43
-    // How to update the database schema for this module
44
-    private const SCHEMA_TARGET_VERSION   = 3;
45
-    private const SCHEMA_SETTING_NAME     = 'MAJ_SOSA_SCHEMA_VERSION';
46
-    private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema';
43
+	// How to update the database schema for this module
44
+	private const SCHEMA_TARGET_VERSION   = 3;
45
+	private const SCHEMA_SETTING_NAME     = 'MAJ_SOSA_SCHEMA_VERSION';
46
+	private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema';
47 47
     
48
-    /**
49
-     * {@inheritDoc}
50
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
51
-     */
52
-    public function title(): string
53
-    {
54
-        return /* I18N: Name of the “Sosa” module */ I18N::translate('Sosa');
55
-    }
48
+	/**
49
+	 * {@inheritDoc}
50
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
51
+	 */
52
+	public function title(): string
53
+	{
54
+		return /* I18N: Name of the “Sosa” module */ I18N::translate('Sosa');
55
+	}
56 56
     
57
-    /**
58
-     * {@inheritDoc}
59
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
60
-     */
61
-    public function description(): string
62
-    {
63
-        return /* I18N: Description of the “Sosa” module */ I18N::translate('Calculate and display Sosa ancestors of the root person.');
64
-    }
57
+	/**
58
+	 * {@inheritDoc}
59
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
60
+	 */
61
+	public function description(): string
62
+	{
63
+		return /* I18N: Description of the “Sosa” module */ I18N::translate('Calculate and display Sosa ancestors of the root person.');
64
+	}
65 65
     
66
-    /**
67
-     * {@inheritDoc}
68
-     * @see \MyArtJaub\Webtrees\Module\AbstractModuleMaj::boot()
69
-     */
70
-    public function boot(): void
71
-    {
72
-        parent::boot();
73
-        app(MigrationService::class)->updateSchema(
74
-            self::SCHEMA_MIGRATION_PREFIX,
75
-            self::SCHEMA_SETTING_NAME,
76
-            self::SCHEMA_TARGET_VERSION
77
-        );
78
-    }
66
+	/**
67
+	 * {@inheritDoc}
68
+	 * @see \MyArtJaub\Webtrees\Module\AbstractModuleMaj::boot()
69
+	 */
70
+	public function boot(): void
71
+	{
72
+		parent::boot();
73
+		app(MigrationService::class)->updateSchema(
74
+			self::SCHEMA_MIGRATION_PREFIX,
75
+			self::SCHEMA_SETTING_NAME,
76
+			self::SCHEMA_TARGET_VERSION
77
+		);
78
+	}
79 79
     
80
-    /**
81
-     * {@inheritDoc}
82
-     * @see \MyArtJaub\Webtrees\Module\AbstractModuleMaj::loadRoutes()
83
-     */
84
-    public function loadRoutes(Map $router): void
85
-    {
86
-        $router->attach('', '', static function(Map $router) : void {
87
-            $router->attach('', '/module-maj/sosa', static function(Map $router) : void {
88
-                $router->attach('', '/list', static function (Map $router) : void {
80
+	/**
81
+	 * {@inheritDoc}
82
+	 * @see \MyArtJaub\Webtrees\Module\AbstractModuleMaj::loadRoutes()
83
+	 */
84
+	public function loadRoutes(Map $router): void
85
+	{
86
+		$router->attach('', '', static function(Map $router) : void {
87
+			$router->attach('', '/module-maj/sosa', static function(Map $router) : void {
88
+				$router->attach('', '/list', static function (Map $router) : void {
89 89
                     
90
-                    $router->get(AncestorsList::class, '/ancestors/{tree}/{/gen}', AncestorsList::class);
91
-                    $router->get(MissingAncestorsList::class, '/missing/{tree}/{/gen}', MissingAncestorsList::class);
92
-                });
90
+					$router->get(AncestorsList::class, '/ancestors/{tree}/{/gen}', AncestorsList::class);
91
+					$router->get(MissingAncestorsList::class, '/missing/{tree}/{/gen}', MissingAncestorsList::class);
92
+				});
93 93
                 
94
-                $router->get(SosaStatistics::class, '/statistics/{tree}', SosaStatistics::class);
94
+				$router->get(SosaStatistics::class, '/statistics/{tree}', SosaStatistics::class);
95 95
                 
96
-                $router->attach('', '/config/{tree}', static function (Map $router) : void {
96
+				$router->attach('', '/config/{tree}', static function (Map $router) : void {
97 97
                     
98
-                    $router->get(SosaConfig::class, '', SosaConfig::class);
99
-                    $router->post(SosaConfigAction::class, '', SosaConfigAction::class);
98
+					$router->get(SosaConfig::class, '', SosaConfig::class);
99
+					$router->post(SosaConfigAction::class, '', SosaConfigAction::class);
100 100
                     
101
-                    $router->post(SosaComputeAction::class, '/compute', SosaComputeAction::class);
102
-                });
103
-            });
104
-        });
105
-    }
101
+					$router->post(SosaComputeAction::class, '/compute', SosaComputeAction::class);
102
+				});
103
+			});
104
+		});
105
+	}
106 106
     
107
-    /**
108
-     * {@inheritDoc}
109
-     * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion()
110
-     */
111
-    public function customModuleVersion(): string
112
-    {
113
-        return '2.0.7-v.1';
114
-    }
107
+	/**
108
+	 * {@inheritDoc}
109
+	 * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion()
110
+	 */
111
+	public function customModuleVersion(): string
112
+	{
113
+		return '2.0.7-v.1';
114
+	}
115 115
     
116
-    /**
117
-     * {@inheritDoc}
118
-     * @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::defaultMenuOrder()
119
-     */
120
-    public function defaultMenuOrder(): int
121
-    {
122
-        return 7;
123
-    }
116
+	/**
117
+	 * {@inheritDoc}
118
+	 * @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::defaultMenuOrder()
119
+	 */
120
+	public function defaultMenuOrder(): int
121
+	{
122
+		return 7;
123
+	}
124 124
     
125
-    /**
126
-     * {@inhericDoc}
127
-     * @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::getMenu()
128
-     */
129
-    public function getMenu(Tree $tree): ?Menu
130
-    {
131
-        $menu = new Menu(I18N::translate('Sosa Statistics'));
132
-        $menu->setClass('menu-maj-sosa');
125
+	/**
126
+	 * {@inhericDoc}
127
+	 * @see \Fisharebest\Webtrees\Module\ModuleMenuInterface::getMenu()
128
+	 */
129
+	public function getMenu(Tree $tree): ?Menu
130
+	{
131
+		$menu = new Menu(I18N::translate('Sosa Statistics'));
132
+		$menu->setClass('menu-maj-sosa');
133 133
         
134
-        $menu->setSubmenus([
135
-            new Menu(I18N::translate('Sosa Ancestors'), route(AncestorsList::class, ['tree' => $tree->name()]), 'menu-maj-sosa-list', ['rel' => 'nofollow']),
136
-            new Menu(I18N::translate('Missing Ancestors'), route(MissingAncestorsList::class, ['tree' => $tree->name()]),  'menu-maj-sosa-missing', ['rel' => 'nofollow']),
137
-            new Menu(I18N::translate('Sosa Statistics'), route(SosaStatistics::class, ['tree' => $tree->name()]), 'menu-maj-sosa-stats')
138
-        ]);
134
+		$menu->setSubmenus([
135
+			new Menu(I18N::translate('Sosa Ancestors'), route(AncestorsList::class, ['tree' => $tree->name()]), 'menu-maj-sosa-list', ['rel' => 'nofollow']),
136
+			new Menu(I18N::translate('Missing Ancestors'), route(MissingAncestorsList::class, ['tree' => $tree->name()]),  'menu-maj-sosa-missing', ['rel' => 'nofollow']),
137
+			new Menu(I18N::translate('Sosa Statistics'), route(SosaStatistics::class, ['tree' => $tree->name()]), 'menu-maj-sosa-stats')
138
+		]);
139 139
         
140
-        if(Auth::check()) {
141
-            $menu->addSubmenu(
142
-                new Menu(I18N::translate('Sosa Configuration'), route(SosaConfig::class, ['tree' => $tree->name()]), 'menu-maj-sosa-config')
143
-            );
144
-        }
140
+		if(Auth::check()) {
141
+			$menu->addSubmenu(
142
+				new Menu(I18N::translate('Sosa Configuration'), route(SosaConfig::class, ['tree' => $tree->name()]), 'menu-maj-sosa-config')
143
+			);
144
+		}
145 145
         
146
-        return $menu;
147
-    }
146
+		return $menu;
147
+	}
148 148
     
149
-    /**
150
-     * {@inheritDoc}
151
-     * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent()
152
-     */
153
-    public function headContent(): string
154
-    {
155
-        return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">';
156
-    }
149
+	/**
150
+	 * {@inheritDoc}
151
+	 * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent()
152
+	 */
153
+	public function headContent(): string
154
+	{
155
+		return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">';
156
+	}
157 157
 }
158 158
  
159 159
\ No newline at end of file
Please login to merge, or discard this patch.