@@ -30,337 +30,337 @@ |
||
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 | } |
@@ -122,8 +122,7 @@ discard block |
||
122 | 122 | ->selectRaw('SUM(majs_gen * majs_gen) AS sum_x2') |
123 | 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)); |
|
125 | + return $row->n == 0 ? 0 : -($row->n * $row->sum_xy - $row->sum_x * $row->sum_y) / ($row->n * $row->sum_x2 - pow($row->sum_x, 2)); |
|
127 | 126 | } |
128 | 127 | |
129 | 128 | /** |
@@ -146,11 +145,11 @@ discard block |
||
146 | 145 | $cumul_stats_by_gen = $this->statisticsByGenerationCumulativeData(); |
147 | 146 | |
148 | 147 | $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, |
|
148 | + foreach ($stats_by_gen as $gen => $stats_gen) { |
|
149 | + $statistics_by_gen[(int)$stats_gen->gen] = array( |
|
150 | + 'sosaCount' => (int)$stats_gen->total_sosa, |
|
151 | + 'sosaTotalCount' => (int)$cumul_stats_by_gen[$gen]->total_cumul, |
|
152 | + 'diffSosaTotalCount' => (int)$cumul_stats_by_gen[$gen]->total_distinct_cumul, |
|
154 | 153 | 'firstBirth' => $stats_gen->first_year, |
155 | 154 | 'firstEstimatedBirth' => $stats_gen->first_est_year, |
156 | 155 | 'lastBirth' => $stats_gen->last_year, |
@@ -228,17 +227,17 @@ discard block |
||
228 | 227 | { |
229 | 228 | $table_prefix = DB::connection()->getTablePrefix(); |
230 | 229 | $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') |
|
230 | + ->selectRaw($table_prefix.'sosa.majs_gen - ? AS majs_gen_norm', [$gen]) |
|
231 | + ->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]) |
|
232 | + ->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') |
|
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 0 ELSE 1 END) As semi_root_count') |
|
235 | 234 | ->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') |
|
235 | + $join->whereRaw($table_prefix.'sosa_fat.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa') |
|
237 | 236 | ->where('sosa_fat.majs_gedcom_id', '=', $this->tree->id()) |
238 | 237 | ->where('sosa_fat.majs_user_id', '=', $this->user->id()); |
239 | 238 | }) |
240 | 239 | ->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') |
|
240 | + $join->whereRaw($table_prefix.'sosa_mot.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa + 1') |
|
242 | 241 | ->where('sosa_mot.majs_gedcom_id', '=', $this->tree->id()) |
243 | 242 | ->where('sosa_mot.majs_user_id', '=', $this->user->id()); |
244 | 243 | }) |
@@ -287,14 +286,14 @@ discard block |
||
287 | 286 | $table_prefix = DB::connection()->getTablePrefix(); |
288 | 287 | $multiple_ancestors = DB::table('maj_sosa AS sosa') |
289 | 288 | ->select('sosa.majs_i_id AS sosa_i_id') |
290 | - ->selectRaw('COUNT('. $table_prefix .'sosa.majs_sosa) AS sosa_count') |
|
289 | + ->selectRaw('COUNT('.$table_prefix.'sosa.majs_sosa) AS sosa_count') |
|
291 | 290 | ->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') |
|
291 | + $join->whereRaw($table_prefix.'sosa_fat.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa') |
|
293 | 292 | ->where('sosa_fat.majs_gedcom_id', '=', $this->tree->id()) |
294 | 293 | ->where('sosa_fat.majs_user_id', '=', $this->user->id()); |
295 | 294 | }) |
296 | 295 | ->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') |
|
296 | + $join->whereRaw($table_prefix.'sosa_mot.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa + 1') |
|
298 | 297 | ->where('sosa_mot.majs_gedcom_id', '=', $this->tree->id()) |
299 | 298 | ->where('sosa_mot.majs_user_id', '=', $this->user->id()); |
300 | 299 | }) |
@@ -303,16 +302,16 @@ discard block |
||
303 | 302 | ->whereNull('sosa_fat.majs_sosa') // We keep only root individuals, i.e. those with no father or mother |
304 | 303 | ->whereNull('sosa_mot.majs_sosa') |
305 | 304 | ->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') |
|
305 | + ->havingRaw('COUNT('.$table_prefix.'sosa.majs_sosa) > 1') // Limit to the duplicate sosas. |
|
306 | + ->orderByRaw('COUNT('.$table_prefix.'sosa.majs_sosa) DESC, MIN('.$table_prefix.'sosa.majs_sosa) ASC') |
|
308 | 307 | ->limit($limit + 1) // We want to select one more than required, for ties |
309 | 308 | ->get(); |
310 | 309 | |
311 | - if($multiple_ancestors->count() > $limit) |
|
310 | + if ($multiple_ancestors->count() > $limit) |
|
312 | 311 | { |
313 | 312 | $last_count = $multiple_ancestors->last()->sosa_count; |
314 | 313 | $multiple_ancestors = $multiple_ancestors->reject(function($element) use ($last_count) : bool { |
315 | - return $element->sosa_count == $last_count; |
|
314 | + return $element->sosa_count == $last_count; |
|
316 | 315 | }); |
317 | 316 | } |
318 | 317 | return $multiple_ancestors; |
@@ -25,126 +25,126 @@ |
||
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 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | public function computeAll(): bool |
78 | 78 | { |
79 | 79 | $root_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID'); |
80 | - if($indi = Registry::individualFactory()->make($root_id, $this->tree)) { |
|
80 | + if ($indi = Registry::individualFactory()->make($root_id, $this->tree)) { |
|
81 | 81 | $this->sosa_records_service->deleteAll($this->tree, $this->user); |
82 | 82 | $this->addNode($indi, 1); |
83 | 83 | $this->flushTmpSosaTable(true); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | public function computeFromIndividual(Individual $indi) : bool |
96 | 96 | { |
97 | 97 | $current_sosas = $this->sosa_records_service->getSosaNumbers($indi); |
98 | - foreach(array_keys($current_sosas) as $sosa) { |
|
98 | + foreach (array_keys($current_sosas) as $sosa) { |
|
99 | 99 | $this->sosa_records_service->deleteAncestorsFrom($this->tree, $this->user, $sosa); |
100 | 100 | $this->addNode($indi, $sosa); |
101 | 101 | } |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | |
129 | 129 | $this->flushTmpSosaTable(); |
130 | 130 | |
131 | - if(($fam = $indi->childFamilies()->first()) !== null) { |
|
131 | + if (($fam = $indi->childFamilies()->first()) !== null) { |
|
132 | 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); |
|
133 | + if ($husb = $fam->husband()) $this->addNode($husb, 2 * $sosa); |
|
134 | + if ($wife = $fam->wife()) $this->addNode($wife, 2 * $sosa + 1); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | * @param bool $force Should the flush be forced |
142 | 142 | */ |
143 | 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)){ |
|
144 | + if (count($this->tmp_sosa_table) > 0 && |
|
145 | + ($force || count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)) { |
|
146 | 146 | $this->sosa_records_service->insertOrUpdate($this->tree, $this->user, $this->tmp_sosa_table); |
147 | 147 | $this->tmp_sosa_table = array(); |
148 | 148 | } |
@@ -130,8 +130,12 @@ |
||
130 | 130 | |
131 | 131 | if(($fam = $indi->childFamilies()->first()) !== null) { |
132 | 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); |
|
133 | + if($husb = $fam->husband()) { |
|
134 | + $this->addNode($husb, 2 * $sosa); |
|
135 | + } |
|
136 | + if($wife = $fam->wife()) { |
|
137 | + $this->addNode($wife, 2 * $sosa + 1); |
|
138 | + } |
|
135 | 139 | } |
136 | 140 | } |
137 | 141 |
@@ -37,122 +37,122 @@ |
||
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 |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | // How to update the database schema for this module |
44 | 44 | private const SCHEMA_TARGET_VERSION = 3; |
45 | 45 | private const SCHEMA_SETTING_NAME = 'MAJ_SOSA_SCHEMA_VERSION'; |
46 | - private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
46 | + private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__.'\Schema'; |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * {@inheritDoc} |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | { |
86 | 86 | $router->attach('', '', static function(Map $router) : void { |
87 | 87 | $router->attach('', '/module-maj/sosa', static function(Map $router) : void { |
88 | - $router->attach('', '/list', static function (Map $router) : void { |
|
88 | + $router->attach('', '/list', static function(Map $router) : void { |
|
89 | 89 | |
90 | 90 | $router->get(AncestorsList::class, '/ancestors/{tree}/{/gen}', AncestorsList::class); |
91 | 91 | $router->get(MissingAncestorsList::class, '/missing/{tree}/{/gen}', MissingAncestorsList::class); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 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 | 98 | $router->get(SosaConfig::class, '', SosaConfig::class); |
99 | 99 | $router->post(SosaConfigAction::class, '', SosaConfigAction::class); |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | |
134 | 134 | $menu->setSubmenus([ |
135 | 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']), |
|
136 | + new Menu(I18N::translate('Missing Ancestors'), route(MissingAncestorsList::class, ['tree' => $tree->name()]), 'menu-maj-sosa-missing', ['rel' => 'nofollow']), |
|
137 | 137 | new Menu(I18N::translate('Sosa Statistics'), route(SosaStatistics::class, ['tree' => $tree->name()]), 'menu-maj-sosa-stats') |
138 | 138 | ]); |
139 | 139 | |
140 | - if(Auth::check()) { |
|
140 | + if (Auth::check()) { |
|
141 | 141 | $menu->addSubmenu( |
142 | 142 | new Menu(I18N::translate('Sosa Configuration'), route(SosaConfig::class, ['tree' => $tree->name()]), 'menu-maj-sosa-config') |
143 | 143 | ); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function headContent(): string |
154 | 154 | { |
155 | - return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
155 | + return '<link rel="stylesheet" href="'.e($this->moduleCssUrl()).'">'; |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
159 | 159 | \ No newline at end of file |