summaryrefslogtreecommitdiff
path: root/app/Http/RequestHandlers/ControlPanel.php
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2019-12-09 21:41:50 +0000
committerGreg Roach <fisharebest@webtrees.net>2019-12-10 12:00:29 +0000
commite72c24d6f8af5daa6dc0f4942f8c8f018f99ab41 (patch)
treeab3186aa1569bb5d722c49666229e9c8ff566370 /app/Http/RequestHandlers/ControlPanel.php
parent70fa890628e03c8b96086827335f0e40a8780fc5 (diff)
downloadwebtrees-e72c24d6f8af5daa6dc0f4942f8c8f018f99ab41.tar.gz
webtrees-e72c24d6f8af5daa6dc0f4942f8c8f018f99ab41.tar.bz2
webtrees-e72c24d6f8af5daa6dc0f4942f8c8f018f99ab41.zip
Add submitter list #2823
Diffstat (limited to 'app/Http/RequestHandlers/ControlPanel.php')
-rw-r--r--app/Http/RequestHandlers/ControlPanel.php42
1 files changed, 34 insertions, 8 deletions
diff --git a/app/Http/RequestHandlers/ControlPanel.php b/app/Http/RequestHandlers/ControlPanel.php
index 57741c8763..4c207ebbea 100644
--- a/app/Http/RequestHandlers/ControlPanel.php
+++ b/app/Http/RequestHandlers/ControlPanel.php
@@ -39,12 +39,16 @@ use Fisharebest\Webtrees\Module\ModuleThemeInterface;
use Fisharebest\Webtrees\Module\NoteListModule;
use Fisharebest\Webtrees\Module\RepositoryListModule;
use Fisharebest\Webtrees\Module\SourceListModule;
+use Fisharebest\Webtrees\Module\SubmitterListModule;
+use Fisharebest\Webtrees\Note;
+use Fisharebest\Webtrees\Repository;
use Fisharebest\Webtrees\Services\HousekeepingService;
use Fisharebest\Webtrees\Services\ModuleService;
use Fisharebest\Webtrees\Services\ServerCheckService;
use Fisharebest\Webtrees\Services\TreeService;
use Fisharebest\Webtrees\Services\UpgradeService;
use Fisharebest\Webtrees\Services\UserService;
+use Fisharebest\Webtrees\Submitter;
use Fisharebest\Webtrees\Webtrees;
use Illuminate\Database\Capsule\Manager as DB;
use Illuminate\Database\Query\Expression;
@@ -138,12 +142,14 @@ class ControlPanel implements RequestHandlerInterface
'media' => $this->totalMediaObjects(),
'repositories' => $this->totalRepositories(),
'notes' => $this->totalNotes(),
+ 'submitters' => $this->totalSubmitters(),
'individual_list_module' => $this->module_service->findByInterface(IndividualListModule::class)->first(),
'family_list_module' => $this->module_service->findByInterface(FamilyListModule::class)->first(),
'media_list_module' => $this->module_service->findByInterface(MediaListModule::class)->first(),
'note_list_module' => $this->module_service->findByInterface(NoteListModule::class)->first(),
'repository_list_module' => $this->module_service->findByInterface(RepositoryListModule::class)->first(),
'source_list_module' => $this->module_service->findByInterface(SourceListModule::class)->first(),
+ 'submitter_list_module' => $this->module_service->findByInterface(SubmitterListModule::class)->first(),
'files_to_delete' => $files_to_delete,
'all_modules_disabled' => $this->module_service->all(true),
'all_modules_enabled' => $this->module_service->all(),
@@ -197,7 +203,7 @@ class ControlPanel implements RequestHandlerInterface
/**
* Count the number of individuals in each tree.
*
- * @return Collection
+ * @return Collection<string,int>
*/
private function totalIndividuals(): Collection
{
@@ -213,7 +219,7 @@ class ControlPanel implements RequestHandlerInterface
/**
* Count the number of families in each tree.
*
- * @return Collection
+ * @return Collection<string,int>
*/
private function totalFamilies(): Collection
{
@@ -229,7 +235,7 @@ class ControlPanel implements RequestHandlerInterface
/**
* Count the number of sources in each tree.
*
- * @return Collection
+ * @return Collection<string,int>
*/
private function totalSources(): Collection
{
@@ -245,7 +251,7 @@ class ControlPanel implements RequestHandlerInterface
/**
* Count the number of media objects in each tree.
*
- * @return Collection
+ * @return Collection<string,int>
*/
private function totalMediaObjects(): Collection
{
@@ -261,7 +267,7 @@ class ControlPanel implements RequestHandlerInterface
/**
* Count the number of repositorie in each tree.
*
- * @return Collection
+ * @return Collection<string,int>
*/
private function totalRepositories(): Collection
{
@@ -269,7 +275,7 @@ class ControlPanel implements RequestHandlerInterface
->leftJoin('other', static function (JoinClause $join): void {
$join
->on('o_file', '=', 'gedcom_id')
- ->where('o_type', '=', 'REPO');
+ ->where('o_type', '=', Repository::RECORD_TYPE);
})
->groupBy(['gedcom_id'])
->pluck(new Expression('COUNT(o_id)'), 'gedcom_id')
@@ -281,7 +287,7 @@ class ControlPanel implements RequestHandlerInterface
/**
* Count the number of notes in each tree.
*
- * @return Collection
+ * @return Collection<string,int>
*/
private function totalNotes(): Collection
{
@@ -289,7 +295,27 @@ class ControlPanel implements RequestHandlerInterface
->leftJoin('other', static function (JoinClause $join): void {
$join
->on('o_file', '=', 'gedcom_id')
- ->where('o_type', '=', 'NOTE');
+ ->where('o_type', '=', Note::RECORD_TYPE);
+ })
+ ->groupBy(['gedcom_id'])
+ ->pluck(new Expression('COUNT(o_id)'), 'gedcom_id')
+ ->map(static function (string $count) {
+ return (int) $count;
+ });
+ }
+
+ /**
+ * Count the number of submitters in each tree.
+ *
+ * @return Collection<string,int>
+ */
+ private function totalSubmitters(): Collection
+ {
+ return DB::table('gedcom')
+ ->leftJoin('other', static function (JoinClause $join): void {
+ $join
+ ->on('o_file', '=', 'gedcom_id')
+ ->where('o_type', '=', Submitter::RECORD_TYPE);
})
->groupBy(['gedcom_id'])
->pluck(new Expression('COUNT(o_id)'), 'gedcom_id')