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;
use Elastica\Query\Terms; use Elastica\Query\Terms;
use Psr\Cache\CacheItemPoolInterface; use Psr\Cache\CacheItemPoolInterface;
use swentel\nostr\Key\Key; use swentel\nostr\Key\Key;
use Symfony\Contracts\Cache\CacheInterface;
#[AsCommand(name: 'app:cache_latest_articles', description: 'Cache the latest articles list')] #[AsCommand(name: 'app:cache_latest_articles', description: 'Cache the latest articles list')]
class CacheLatestArticlesCommand extends Command class CacheLatestArticlesCommand extends Command
{ {
private FinderInterface $finder; private FinderInterface $finder;
private CacheItemPoolInterface $articlesCache; private CacheInterface $appCache;
private ParameterBagInterface $params; private ParameterBagInterface $params;
public function __construct(FinderInterface $finder, CacheItemPoolInterface $articlesCache, ParameterBagInterface $params) public function __construct(FinderInterface $finder, CacheItemPoolInterface $articlesCache, ParameterBagInterface $params)

12
src/Command/QualityCheckArticlesCommand.php

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

Loading…
Cancel
Save