mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-04-01 09:35:28 +00:00
update totals block
This commit is contained in:
parent
6397e3d702
commit
1f22cb57e9
2 changed files with 120 additions and 23 deletions
|
|
@ -494,7 +494,7 @@ class Database {
|
||||||
return $query->fetch();
|
return $query->fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUsersTotal() {
|
public function getUsersTotal() : int {
|
||||||
|
|
||||||
$this->_debug->query->select->total++;
|
$this->_debug->query->select->total++;
|
||||||
|
|
||||||
|
|
@ -505,6 +505,24 @@ class Database {
|
||||||
return $query->fetch()->result;
|
return $query->fetch()->result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getUsersTotalByPublic(mixed $public) : int {
|
||||||
|
|
||||||
|
$this->_debug->query->select->total++;
|
||||||
|
|
||||||
|
if (is_null($public))
|
||||||
|
{
|
||||||
|
$query = $this->_db->prepare('SELECT COUNT(*) AS `result` FROM `user` WHERE `public` IS NULL');
|
||||||
|
$query->execute();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$query = $this->_db->prepare('SELECT COUNT(*) AS `result` FROM `user` WHERE `public` = ?');
|
||||||
|
$query->execute([(int) $public]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query->fetch()->result;
|
||||||
|
}
|
||||||
|
|
||||||
public function findUserByAddress(string $address) {
|
public function findUserByAddress(string $address) {
|
||||||
|
|
||||||
$this->_debug->query->select->total++;
|
$this->_debug->query->select->total++;
|
||||||
|
|
@ -632,6 +650,19 @@ class Database {
|
||||||
return $query->fetch()->result;
|
return $query->fetch()->result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMagnetsTotalByUsersPublic(bool $public) : int {
|
||||||
|
|
||||||
|
$this->_debug->query->select->total++;
|
||||||
|
|
||||||
|
$query = $this->_db->prepare('SELECT COUNT(*) AS `result` FROM `magnet`
|
||||||
|
JOIN `user` ON (`user`.`userId` = `magnet`.`userId`)
|
||||||
|
WHERE `user`.`public` = ?');
|
||||||
|
|
||||||
|
$query->execute([(int) $public]);
|
||||||
|
|
||||||
|
return $query->fetch()->result;
|
||||||
|
}
|
||||||
|
|
||||||
public function updateMagnetDn(int $magnetId, string $dn, int $timeUpdated) : int {
|
public function updateMagnetDn(int $magnetId, string $dn, int $timeUpdated) : int {
|
||||||
|
|
||||||
$this->_debug->query->update->total++;
|
$this->_debug->query->update->total++;
|
||||||
|
|
@ -1246,6 +1277,19 @@ class Database {
|
||||||
return $query->fetch()->result;
|
return $query->fetch()->result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMagnetCommentsTotalByUsersPublic(bool $public) : int {
|
||||||
|
|
||||||
|
$this->_debug->query->select->total++;
|
||||||
|
|
||||||
|
$query = $this->_db->prepare('SELECT COUNT(*) AS `result` FROM `magnetComment`
|
||||||
|
JOIN `user` ON (`user`.`userId` = `magnetComment`.`userId`)
|
||||||
|
WHERE `user`.`public` = ?');
|
||||||
|
|
||||||
|
$query->execute([(int) $public]);
|
||||||
|
|
||||||
|
return $query->fetch()->result;
|
||||||
|
}
|
||||||
|
|
||||||
public function getMagnetComments(int $magnetId, mixed $magnetCommentIdParent = null) {
|
public function getMagnetComments(int $magnetId, mixed $magnetCommentIdParent = null) {
|
||||||
|
|
||||||
$this->_debug->query->select->total++;
|
$this->_debug->query->select->total++;
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,20 @@ else if (is_null($user->public))
|
||||||
<?php echo Time::ago((int) $user->timeUpdated) ?>
|
<?php echo Time::ago((int) $user->timeUpdated) ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<!--
|
||||||
|
<tr>
|
||||||
|
<td><?php echo _('Magnets') ?></td>
|
||||||
|
<td>
|
||||||
|
<?php echo $db->getMagnetsTotalByUserId($user->userId) ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo _('Comments') ?></td>
|
||||||
|
<td>
|
||||||
|
<?php echo $db->getMagnetCommentsTotalByUserId($user->userId) ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
-->
|
||||||
<tr>
|
<tr>
|
||||||
<td class="padding-b-8 border-bottom-default text-right" colspan="2">
|
<td class="padding-b-8 border-bottom-default text-right" colspan="2">
|
||||||
<?php echo _('Rules') ?>
|
<?php echo _('Rules') ?>
|
||||||
|
|
@ -137,38 +151,77 @@ else if (is_null($user->public))
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="padding-t-16"><?php echo _('Users') ?></td>
|
<td class="padding-t-16"><?php echo _('Users') ?></td>
|
||||||
<td class="padding-t-16"><?php echo $db->getUsersTotal() ?></td>
|
<td class="padding-t-16">
|
||||||
</tr>
|
<?php echo $db->getUsersTotal() ?>
|
||||||
<tr>
|
<?php if ($usersTotalByPublicTrue = $db->getUsersTotalByPublic(true)) { ?>
|
||||||
<td><?php echo _('Magnets') ?></td>
|
|
||||||
<td>
|
|
||||||
<?php echo $db->getMagnetsTotal() ?>
|
|
||||||
/
|
/
|
||||||
<span class="cursor-default <?php echo $user->public ? 'text-color-green' : 'text-color-pink' ?>">
|
<span class="cursor-default text-color-green">
|
||||||
<?php echo $db->getMagnetsTotalByUserId($user->userId) ?>
|
<?php echo $usersTotalByPublicTrue ?>
|
||||||
<sub class="text-color-default opacity-0 parent-hover-opacity-09" title="<?php echo $user->public ? _('Your magnets on this instance (Distributed access)') : _('Your magnets on this instance (local access level)') ?>">
|
</span>
|
||||||
|
<?php } ?>
|
||||||
|
<?php if ($usersTotalByPublicFalse = $db->getUsersTotalByPublic(false)) { ?>
|
||||||
|
/
|
||||||
|
<span class="cursor-default text-color-pink">
|
||||||
|
<?php echo $usersTotalByPublicFalse ?>
|
||||||
|
</span>
|
||||||
|
<?php } ?>
|
||||||
|
<sub class="opacity-0 parent-hover-opacity-09" title="<?php echo _('total') .
|
||||||
|
($usersTotalByPublicTrue ? sprintf(' / %s', _('distributed')) : false) .
|
||||||
|
($usersTotalByPublicFalse ? sprintf(' / %s', _('local')) : false) ?>">
|
||||||
<svg class="width-13px" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-info-circle-fill" viewBox="0 0 16 16">
|
<svg class="width-13px" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-info-circle-fill" viewBox="0 0 16 16">
|
||||||
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
|
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
|
||||||
</svg>
|
</svg>
|
||||||
</sub>
|
</sub>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo _('Magnets') ?></td>
|
||||||
|
<td class="cursor-default">
|
||||||
|
<?php echo $db->getMagnetsTotal() ?>
|
||||||
|
<?php if ($magnetsTotalByUsersPublicTrue = $db->getMagnetsTotalByUsersPublic(true)) { ?>
|
||||||
|
/
|
||||||
|
<span class="text-color-green">
|
||||||
|
<?php echo $magnetsTotalByUsersPublicTrue ?>
|
||||||
</span>
|
</span>
|
||||||
|
<?php } ?>
|
||||||
|
<?php if ($magnetsTotalByUsersPublicFalse = $db->getMagnetsTotalByUsersPublic(false)) { ?>
|
||||||
|
/
|
||||||
|
<span class="text-color-pink">
|
||||||
|
<?php echo $magnetsTotalByUsersPublicFalse ?>
|
||||||
|
</span>
|
||||||
|
<?php } ?>
|
||||||
|
<sub class="opacity-0 parent-hover-opacity-09" title="<?php echo _('total') .
|
||||||
|
($magnetsTotalByUsersPublicTrue ? sprintf(' / %s', _('distributed')) : false) .
|
||||||
|
($magnetsTotalByUsersPublicFalse ? sprintf(' / %s', _('local')) : false) ?>">
|
||||||
|
<svg class="width-13px" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-info-circle-fill" viewBox="0 0 16 16">
|
||||||
|
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
|
||||||
|
</svg>
|
||||||
|
</sub>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo _('Comments') ?></td>
|
<td><?php echo _('Comments') ?></td>
|
||||||
<td>
|
<td class="cursor-default">
|
||||||
<?php echo $db->getMagnetCommentsTotal() ?>
|
<?php echo $db->getMagnetCommentsTotal() ?>
|
||||||
<?php if ($userMagnetCommentsTotal = $db->getMagnetCommentsTotalByUserId($user->userId)) { ?>
|
<?php if ($magnetCommentsTotalByUsersPublicTrue = $db->getMagnetCommentsTotalByUsersPublic(true)) { ?>
|
||||||
/
|
/
|
||||||
<span class="cursor-default <?php echo $user->public ? 'text-color-green' : 'text-color-pink' ?>">
|
<span class="text-color-green">
|
||||||
<?php echo $userMagnetCommentsTotal ?>
|
<?php echo $magnetCommentsTotalByUsersPublicTrue ?>
|
||||||
<sub class="text-color-default opacity-0 parent-hover-opacity-09" title="<?php echo $user->public ? _('Your comments on this instance (Distributed access)') : _('Your comments on this instance (local access level)') ?>">
|
</span>
|
||||||
|
<?php } ?>
|
||||||
|
<?php if ($magnetCommentsTotalByUsersPublicFalse = $db->getMagnetCommentsTotalByUsersPublic(false)) { ?>
|
||||||
|
/
|
||||||
|
<span class="text-color-pink">
|
||||||
|
<?php echo $magnetCommentsTotalByUsersPublicFalse ?>
|
||||||
|
</span>
|
||||||
|
<?php } ?>
|
||||||
|
<sub class="opacity-0 parent-hover-opacity-09" title="<?php echo _('total') .
|
||||||
|
($magnetCommentsTotalByUsersPublicTrue ? sprintf(' / %s', _('distributed')) : false) .
|
||||||
|
($magnetCommentsTotalByUsersPublicFalse ? sprintf(' / %s', _('local')) : false) ?>">
|
||||||
<svg class="width-13px" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-info-circle-fill" viewBox="0 0 16 16">
|
<svg class="width-13px" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-info-circle-fill" viewBox="0 0 16 16">
|
||||||
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
|
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
|
||||||
</svg>
|
</svg>
|
||||||
</sub>
|
</sub>
|
||||||
</span>
|
|
||||||
<?php } ?>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue