Browse Source

fix stars counter

main
ghost 1 year ago
parent
commit
74e7035123
  1. 8
      src/library/database.php
  2. 2
      src/public/index.php
  3. 2
      src/public/magnet.php

8
src/library/database.php

@ -1382,13 +1382,15 @@ class Database {
return $query->fetch()->result; return $query->fetch()->result;
} }
public function findMagnetStarsTotalByMagnetId(int $magnetId) : int { public function findMagnetStarsTotalByMagnetId(int $magnetId, bool $value) : int {
$this->_debug->query->select->total++; $this->_debug->query->select->total++;
$query = $this->_db->prepare('SELECT COUNT(DISTINCT `userId`) AS `result` FROM `magnetStar` WHERE `magnetId` = ?'); $total = 0;
$query->execute([$magnetId]); $query = $this->_db->prepare('SELECT COUNT(DISTINCT `userId`) AS `result` FROM `magnetStar` WHERE `magnetId` = ? AND `value` = ?');
$query->execute([$magnetId, (int) $value]);
return $query->fetch()->result; return $query->fetch()->result;
} }

2
src/public/index.php

@ -143,7 +143,7 @@ else
], ],
'star' => (object) 'star' => (object)
[ [
'total' => $db->findMagnetStarsTotalByMagnetId($magnet->magnetId), 'total' => $db->findMagnetStarsTotalByMagnetId($magnet->magnetId, true),
'status' => $db->findLastMagnetStarValue($magnet->magnetId, $userId), 'status' => $db->findLastMagnetStarValue($magnet->magnetId, $userId),
], ],
'access' => (object) 'access' => (object)

2
src/public/magnet.php

@ -131,7 +131,7 @@ else
], ],
'star' => (object) 'star' => (object)
[ [
'total' => $db->findMagnetStarsTotalByMagnetId($magnet->magnetId), 'total' => $db->findMagnetStarsTotalByMagnetId($magnet->magnetId, true),
'status' => $db->findLastMagnetStarValue($magnet->magnetId, $userId), 'status' => $db->findLastMagnetStarValue($magnet->magnetId, $userId),
], ],
'access' => (object) 'access' => (object)

Loading…
Cancel
Save