Improved performance of "hide downvoted"
This commit is contained in:
parent
88dfc0eb96
commit
20d75e177d
4 changed files with 18 additions and 6 deletions
|
@ -156,15 +156,15 @@ class PostDao extends AbstractDao implements ICrudDao
|
|||
$values = $requirement->getValue()->getValues();
|
||||
$userName = $values[0];
|
||||
$score = $values[1];
|
||||
$userId = $this->userDao->findByName($userName)->getId();
|
||||
$sql = 'EXISTS (
|
||||
SELECT 1 FROM scores
|
||||
INNER JOIN users ON scores.userId = users.id
|
||||
WHERE scores.postId = posts.id
|
||||
AND LOWER(users.name) = LOWER(?)
|
||||
AND scores.userId = ?
|
||||
AND scores.score = ?)';
|
||||
if ($requirement->isnegated())
|
||||
if ($requirement->isNegated())
|
||||
$sql = 'NOT ' . $sql;
|
||||
$query->where($sql, [$userName, $score]);
|
||||
$query->where($sql, [$userId, $score]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@ class Upgrade25 implements IUpgrade
|
|||
public function run(DatabaseConnection $databaseConnection)
|
||||
{
|
||||
$pdo = $databaseConnection->getPDO();
|
||||
|
||||
$pdo->exec('ALTER TABLE tags ADD COLUMN category VARCHAR(25)');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
13
src/Upgrades/Upgrade26.php
Normal file
13
src/Upgrades/Upgrade26.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
namespace Szurubooru\Upgrades;
|
||||
use Szurubooru\DatabaseConnection;
|
||||
|
||||
class Upgrade26 implements IUpgrade
|
||||
{
|
||||
public function run(DatabaseConnection $databaseConnection)
|
||||
{
|
||||
$pdo = $databaseConnection->getPDO();
|
||||
$pdo->exec('CREATE INDEX idx_scores_commentId ON scores(commentId)');
|
||||
$pdo->exec('CREATE INDEX idx_scores_postId ON scores(postId)');
|
||||
}
|
||||
}
|
|
@ -41,6 +41,7 @@ return [
|
|||
$container->get(\Szurubooru\Upgrades\Upgrade23::class),
|
||||
$container->get(\Szurubooru\Upgrades\Upgrade24::class),
|
||||
$container->get(\Szurubooru\Upgrades\Upgrade25::class),
|
||||
$container->get(\Szurubooru\Upgrades\Upgrade26::class),
|
||||
];
|
||||
}),
|
||||
|
||||
|
|
Loading…
Reference in a new issue