@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | $cache = Registry::cache()->file(); |
44 | 44 | |
45 | 45 | return $cache->remember( |
46 | - $module->name() . '-matomovisits-yearly-' . $block_id, |
|
47 | - function () use ($module, $block_id): ?int { |
|
46 | + $module->name().'-matomovisits-yearly-'.$block_id, |
|
47 | + function() use ($module, $block_id): ?int { |
|
48 | 48 | $visits_year = $this->visits($module, $block_id, 'year'); |
49 | 49 | if ($visits_year === null) { |
50 | 50 | return null; |
51 | 51 | } |
52 | - $visits_today = (int) $this->visits($module, $block_id, 'day'); |
|
52 | + $visits_today = (int)$this->visits($module, $block_id, 'day'); |
|
53 | 53 | |
54 | 54 | return $visits_year - $visits_today; |
55 | 55 | }, |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | public function visitsToday(WelcomeBlockModule $module, int $block_id): ?int |
68 | 68 | { |
69 | 69 | return app('cache.array')->remember( |
70 | - $module->name() . '-matomovisits-daily-' . $block_id, |
|
71 | - function () use ($module, $block_id): ?int { |
|
70 | + $module->name().'-matomovisits-daily-'.$block_id, |
|
71 | + function() use ($module, $block_id) : ?int { |
|
72 | 72 | return $this->visits($module, $block_id, 'day'); |
73 | 73 | } |
74 | 74 | ); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | ]); |
111 | 111 | |
112 | 112 | if ($response->getStatusCode() === StatusCodeInterface::STATUS_OK) { |
113 | - $result = json_decode((string) $response->getBody(), true)['value'] ?? null; |
|
113 | + $result = json_decode((string)$response->getBody(), true)['value'] ?? null; |
|
114 | 114 | if ($result !== null) { |
115 | 115 | return (int)$result; |
116 | 116 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | //How to update the database schema for this module |
52 | 52 | private const SCHEMA_TARGET_VERSION = 2; |
53 | 53 | private const SCHEMA_SETTING_NAME = 'MAJ_ADMTASKS_SCHEMA_VERSION'; |
54 | - private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
54 | + private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__.'\Schema'; |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * {@inheritDoc} |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function loadRoutes(Map $router): void |
93 | 93 | { |
94 | - $router->attach('', '', static function (Map $router): void { |
|
94 | + $router->attach('', '', static function(Map $router): void { |
|
95 | 95 | |
96 | - $router->attach('', '/module-maj/admintasks', static function (Map $router): void { |
|
96 | + $router->attach('', '/module-maj/admintasks', static function(Map $router): void { |
|
97 | 97 | |
98 | - $router->attach('', '/admin', static function (Map $router): void { |
|
98 | + $router->attach('', '/admin', static function(Map $router): void { |
|
99 | 99 | |
100 | 100 | $router->extras([ |
101 | 101 | 'middleware' => [ |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | ]); |
105 | 105 | $router->get(AdminConfigPage::class, '/config', AdminConfigPage::class); |
106 | 106 | |
107 | - $router->attach('', '/tasks', static function (Map $router): void { |
|
107 | + $router->attach('', '/tasks', static function(Map $router): void { |
|
108 | 108 | |
109 | 109 | $router->get(TasksList::class, '', TasksList::class); |
110 | 110 | $router->get(TaskEditPage::class, '/{task}', TaskEditPage::class); |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function bodyContent(): string |
148 | 148 | { |
149 | - return view($this->name() . '::snippet', [ 'url' => route(TaskTrigger::class) ]); |
|
149 | + return view($this->name().'::snippet', ['url' => route(TaskTrigger::class)]); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | $task_schedules = $this->taskschedules_service->all(true, true) |
77 | - ->map(function (TaskSchedule $value): array { |
|
77 | + ->map(function(TaskSchedule $value): array { |
|
78 | 78 | |
79 | 79 | $row = $value->toArray(); |
80 | 80 | $task = $this->taskschedules_service->findTask($row['task_id']); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $sort_columns = ['task_name', 'enabled', 'last_run']; |
87 | 87 | $module_name = $this->module->name(); |
88 | 88 | |
89 | - $callback = function (array $row) use ($module_name): array { |
|
89 | + $callback = function(array $row) use ($module_name): array { |
|
90 | 90 | |
91 | 91 | $row['frequency']->setLocale(I18N::locale()->code()); |
92 | 92 | |
@@ -109,21 +109,20 @@ discard block |
||
109 | 109 | ]; |
110 | 110 | |
111 | 111 | $datum = [ |
112 | - view($module_name . '::admin/tasks-table-options', $task_options_params), |
|
113 | - view($module_name . '::components/yes-no-icons', ['yes' => $row['enabled']]), |
|
114 | - '<span dir="auto">' . e($row['task_name']) . '</span>', |
|
112 | + view($module_name.'::admin/tasks-table-options', $task_options_params), |
|
113 | + view($module_name.'::components/yes-no-icons', ['yes' => $row['enabled']]), |
|
114 | + '<span dir="auto">'.e($row['task_name']).'</span>', |
|
115 | 115 | $row['last_run']->unix() === 0 ? |
116 | - view('components/datetime', ['timestamp' => $row['last_run']]) : |
|
117 | - view('components/datetime-diff', ['timestamp' => $row['last_run']]), |
|
118 | - view($module_name . '::components/yes-no-icons', ['yes' => $row['last_result']]), |
|
119 | - '<span dir="auto">' . e($row['frequency']->cascade()->forHumans()) . '</span>', |
|
116 | + view('components/datetime', ['timestamp' => $row['last_run']]) : view('components/datetime-diff', ['timestamp' => $row['last_run']]), |
|
117 | + view($module_name.'::components/yes-no-icons', ['yes' => $row['last_result']]), |
|
118 | + '<span dir="auto">'.e($row['frequency']->cascade()->forHumans()).'</span>', |
|
120 | 119 | $row['nb_occurrences'] > 0 ? I18N::number($row['nb_occurrences']) : I18N::translate('Unlimited'), |
121 | - view($module_name . '::components/yes-no-icons', [ |
|
120 | + view($module_name.'::components/yes-no-icons', [ |
|
122 | 121 | 'yes' => $row['is_running'], |
123 | 122 | 'text_yes' => I18N::translate('Running'), |
124 | 123 | 'text_no' => I18N::translate('Not running') |
125 | 124 | ]), |
126 | - view($module_name . '::admin/tasks-table-run', $task_run_params) |
|
125 | + view($module_name.'::admin/tasks-table-run', $task_run_params) |
|
127 | 126 | ]; |
128 | 127 | |
129 | 128 | return $datum; |
@@ -34,7 +34,7 @@ |
||
34 | 34 | // Clean up previous admin tasks table if it exists |
35 | 35 | DB::schema()->dropIfExists('maj_admintasks'); |
36 | 36 | |
37 | - DB::schema()->create('maj_admintasks', static function (Blueprint $table): void { |
|
37 | + DB::schema()->create('maj_admintasks', static function(Blueprint $table): void { |
|
38 | 38 | |
39 | 39 | $table->increments('majat_id'); |
40 | 40 | $table->string('majat_task_id', 32)->unique(); |
@@ -195,14 +195,14 @@ discard block |
||
195 | 195 | $query = DB::table('maj_admintasks') |
196 | 196 | ->select() |
197 | 197 | ->where('majat_status', '=', 'enabled') |
198 | - ->where(function (Builder $query): void { |
|
198 | + ->where(function(Builder $query): void { |
|
199 | 199 | |
200 | 200 | $query->where('majat_running', '=', 0) |
201 | 201 | ->orWhere('majat_last_run', '<=', Carbon::now()->subSeconds(self::TASK_TIME_OUT)); |
202 | 202 | }); |
203 | 203 | |
204 | 204 | if (!$force) { |
205 | - $query->where(function (Builder $query): void { |
|
205 | + $query->where(function(Builder $query): void { |
|
206 | 206 | |
207 | 207 | $query->where('majat_running', '=', 0) |
208 | 208 | ->orWhereRaw('DATE_ADD(majat_last_run, INTERVAL majat_frequency MINUTE) <= NOW()'); |
@@ -268,17 +268,17 @@ discard block |
||
268 | 268 | */ |
269 | 269 | public static function rowMapper(): Closure |
270 | 270 | { |
271 | - return static function (stdClass $row): TaskSchedule { |
|
271 | + return static function(stdClass $row): TaskSchedule { |
|
272 | 272 | |
273 | 273 | return new TaskSchedule( |
274 | - (int) $row->majat_id, |
|
274 | + (int)$row->majat_id, |
|
275 | 275 | $row->majat_task_id, |
276 | 276 | $row->majat_status === 'enabled', |
277 | 277 | Carbon::parse($row->majat_last_run), |
278 | - (bool) $row->majat_last_result, |
|
278 | + (bool)$row->majat_last_result, |
|
279 | 279 | CarbonInterval::minutes($row->majat_frequency), |
280 | - (int) $row->majat_nb_occur, |
|
281 | - (bool) $row->majat_running |
|
280 | + (int)$row->majat_nb_occur, |
|
281 | + (bool)$row->majat_running |
|
282 | 282 | ); |
283 | 283 | }; |
284 | 284 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | public function changesByRecordType(Tree $tree, int $nb_days): Collection |
80 | 80 | { |
81 | 81 | return DB::table('change') |
82 | - ->joinSub($this->allGedcomRecords($tree), 'gedrecords', function (JoinClause $join) use ($tree): void { |
|
82 | + ->joinSub($this->allGedcomRecords($tree), 'gedrecords', function(JoinClause $join) use ($tree): void { |
|
83 | 83 | |
84 | 84 | $join->on('change.xref', '=', 'gedrecords.ged_id') |
85 | 85 | ->where('change.gedcom_id', '=', $tree->id()); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | new Expression('MAX(log_time) AS lastoccurred') |
116 | 116 | ) |
117 | 117 | ->where('log_type', '=', 'error') |
118 | - ->where(function (Builder $query) use ($tree): void { |
|
118 | + ->where(function(Builder $query) use ($tree): void { |
|
119 | 119 | $query->where('gedcom_id', '=', $tree->id()) |
120 | 120 | ->orWhereNull('gedcom_id'); |
121 | 121 | }) |
@@ -58,12 +58,12 @@ |
||
58 | 58 | assert($tree instanceof Tree); |
59 | 59 | |
60 | 60 | $params = $request->getParsedBody(); |
61 | - $user_id = (int) $params['sosa-userid']; |
|
61 | + $user_id = (int)$params['sosa-userid']; |
|
62 | 62 | $root_id = $params['sosa-rootid'] ?? ''; |
63 | 63 | |
64 | - if(Auth::id() == $user_id || ($user_id == -1 && Auth::isManager($tree))) { |
|
64 | + if (Auth::id() == $user_id || ($user_id == -1 && Auth::isManager($tree))) { |
|
65 | 65 | $user = $user_id == -1 ? new DefaultUser() : $this->user_service->find($user_id); |
66 | - if($user !== null && $root_indi = Registry::individualFactory()->make($root_id, $tree)) { |
|
66 | + if ($user !== null && $root_indi = Registry::individualFactory()->make($root_id, $tree)) { |
|
67 | 67 | $tree->setUserPreference($user, 'MAJ_SOSA_ROOT_ID', $root_indi->xref()); |
68 | 68 | FlashMessages::addMessage(I18N::translate('The root individual has been updated.')); |
69 | 69 | return redirect(route(SosaConfig::class, [ |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | /** @var SosaStatisticsService $sosa_stats_service */ |
71 | 71 | $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]); |
72 | 72 | |
73 | - return $this->viewResponse($this->module->name() . '::statistics-page', [ |
|
73 | + return $this->viewResponse($this->module->name().'::statistics-page', [ |
|
74 | 74 | 'module_name' => $this->module->name(), |
75 | 75 | 'title' => I18N::translate('Sosa Statistics'), |
76 | 76 | 'tree' => $tree, |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | |
122 | 122 | $generation_stats = array(); |
123 | 123 | |
124 | - foreach($stats_by_gen as $gen => $stats_gen){ |
|
125 | - $gen_diff = $gen > 1 ?$stats_gen['diffSosaTotalCount'] - $stats_by_gen[$gen - 1]['diffSosaTotalCount'] : 1; |
|
124 | + foreach ($stats_by_gen as $gen => $stats_gen) { |
|
125 | + $gen_diff = $gen > 1 ? $stats_gen['diffSosaTotalCount'] - $stats_by_gen[$gen - 1]['diffSosaTotalCount'] : 1; |
|
126 | 126 | $generation_stats[$gen] = array( |
127 | 127 | 'gen_min_birth' => $stats_gen['firstBirth'] ?? $stats_gen['firstEstimatedBirth'], |
128 | 128 | 'gen_max_birth' => $stats_gen['lastBirth'] ?? $stats_gen['lastEstimatedBirth'], |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | 'known' => $stats_gen['sosaCount'], |
131 | 131 | 'perc_known' => $this->safeDivision($stats_gen['sosaCount'], pow(2, $gen - 1)), |
132 | 132 | 'missing' => $gen > 1 ? 2 * $stats_by_gen[$gen - 1]['sosaCount'] - $stats_gen['sosaCount'] : 0, |
133 | - 'perc_missing' => $gen > 1 ? 1 - $this->safeDivision($stats_gen['sosaCount'], 2 * $stats_by_gen[$gen - 1]['sosaCount']) : 0, |
|
133 | + 'perc_missing' => $gen > 1 ? 1 - $this->safeDivision($stats_gen['sosaCount'], 2 * $stats_by_gen[$gen - 1]['sosaCount']) : 0, |
|
134 | 134 | 'total_known' => $stats_gen['sosaTotalCount'], |
135 | 135 | 'perc_total_known' => $this->safeDivision($stats_gen['sosaTotalCount'], pow(2, $gen) - 1), |
136 | 136 | 'different' => $gen_diff, |
@@ -56,16 +56,16 @@ |
||
56 | 56 | $tree = $request->getAttribute('tree'); |
57 | 57 | assert($tree instanceof Tree); |
58 | 58 | |
59 | - $user_id = (int) ($request->getParsedBody()['user_id'] ?? 0); |
|
59 | + $user_id = (int)($request->getParsedBody()['user_id'] ?? 0); |
|
60 | 60 | $partial_from = $request->getParsedBody()['partial_from'] ?? null; |
61 | 61 | |
62 | - if(($user_id == -1 && Auth::isManager($tree)) || Auth::id() == $user_id) { |
|
62 | + if (($user_id == -1 && Auth::isManager($tree)) || Auth::id() == $user_id) { |
|
63 | 63 | $user = $user_id == -1 ? new DefaultUser() : $this->user_service->find($user_id); |
64 | 64 | |
65 | 65 | /** @var SosaCalculatorService $sosa_calc_service */ |
66 | - $sosa_calc_service = app()->makeWith(SosaCalculatorService::class, [ 'tree' => $tree, 'user' => $user]); |
|
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)) { |
|
68 | + if ($partial_from !== null && $sosa_from = Registry::individualFactory()->make($partial_from, $tree)) { |
|
69 | 69 | $res = $sosa_calc_service->computeFromIndividual($sosa_from); |
70 | 70 | } else { |
71 | 71 | $res = $sosa_calc_service->computeAll(); |