Browse Source

Xtra filter

imwald
Nuša Pukšič 3 months ago
parent
commit
4ee3191e47
  1. 3
      src/Command/CacheLatestArticlesCommand.php
  2. 12
      src/Command/QualityCheckArticlesCommand.php

3
src/Command/CacheLatestArticlesCommand.php

@ -16,12 +16,13 @@ use Elastica\Collapse; @@ -16,12 +16,13 @@ use Elastica\Collapse;
use Elastica\Query\Terms;
use Psr\Cache\CacheItemPoolInterface;
use swentel\nostr\Key\Key;
use Symfony\Contracts\Cache\CacheInterface;
#[AsCommand(name: 'app:cache_latest_articles', description: 'Cache the latest articles list')]
class CacheLatestArticlesCommand extends Command
{
private FinderInterface $finder;
private CacheItemPoolInterface $articlesCache;
private CacheInterface $appCache;
private ParameterBagInterface $params;
public function __construct(FinderInterface $finder, CacheItemPoolInterface $articlesCache, ParameterBagInterface $params)

12
src/Command/QualityCheckArticlesCommand.php

@ -9,6 +9,7 @@ use App\Enum\IndexStatusEnum; @@ -9,6 +9,7 @@ use App\Enum\IndexStatusEnum;
use Doctrine\ORM\EntityManagerInterface;
use FOS\ElasticaBundle\Persister\ObjectPersister;
use FOS\ElasticaBundle\Persister\ObjectPersisterInterface;
use swentel\nostr\Key\Key;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
@ -17,6 +18,10 @@ use Symfony\Component\Console\Output\OutputInterface; @@ -17,6 +18,10 @@ use Symfony\Component\Console\Output\OutputInterface;
#[AsCommand(name: 'articles:qa', description: 'Mark articles by quality and select which to index')]
class QualityCheckArticlesCommand extends Command
{
private const BLACKLIST = [
'npub1t5d8kcn0hu8zmt6dpkgatd5hwhx76956g7qmdzwnca6fzgprzlhqnqks86'
];
public function __construct(
private readonly EntityManagerInterface $entityManager
)
@ -46,6 +51,13 @@ class QualityCheckArticlesCommand extends Command @@ -46,6 +51,13 @@ class QualityCheckArticlesCommand extends Command
private function meetsCriteria(Article $article): bool
{
// Exclude blacklisted pubkeys
$key = new Key();
if (in_array($key->convertPublicKeyToBech32($article->getPubkey()), self::BLACKLIST, true))
{
return false;
}
$content = $article->getContent();
// No empty title

Loading…
Cancel
Save