forked from wallabag/wallabag
committed by
Nicolas Lœuillet
parent
85065b509f
commit
20578f0b8e
@ -7,6 +7,7 @@ use Doctrine\ORM\NoResultException;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
@ -41,13 +42,19 @@ class ReloadEntryCommand extends Command
|
||||
->setDescription('Reload entries')
|
||||
->setHelp('This command reload entries')
|
||||
->addArgument('username', InputArgument::OPTIONAL, 'Reload entries only for the given user')
|
||||
;
|
||||
->addOption(
|
||||
'only-not-parsed',
|
||||
null,
|
||||
InputOption::VALUE_NONE,
|
||||
'Only reload entries which have `is_not_parsed` set to `true`'
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
$onlyNotParsed = (bool) $input->getOption('only-not-parsed');
|
||||
$userId = null;
|
||||
if ($username = $input->getArgument('username')) {
|
||||
try {
|
||||
@ -61,7 +68,8 @@ class ReloadEntryCommand extends Command
|
||||
}
|
||||
}
|
||||
|
||||
$entryIds = $this->entryRepository->findAllEntriesIdByUserId($userId);
|
||||
$methodName = $onlyNotParsed ? 'findAllEntriesIdByUserIdAndNotParsed' : 'findAllEntriesIdByUserId';
|
||||
$entryIds = $this->entryRepository->$methodName($userId);
|
||||
|
||||
$nbEntries = \count($entryIds);
|
||||
if (!$nbEntries) {
|
||||
|
||||
@ -85,6 +85,7 @@ class EntryFixtures extends Fixture implements DependentFixtureInterface
|
||||
'language' => 'de',
|
||||
'archived' => true,
|
||||
'tags' => ['bar-tag'],
|
||||
'is_not_parsed' => true,
|
||||
],
|
||||
];
|
||||
|
||||
@ -120,6 +121,10 @@ class EntryFixtures extends Fixture implements DependentFixtureInterface
|
||||
$entry->setPreviewPicture($item['preview']);
|
||||
}
|
||||
|
||||
if (isset($item['is_not_parsed'])) {
|
||||
$entry->setNotParsed($item['is_not_parsed']);
|
||||
}
|
||||
|
||||
$manager->persist($entry);
|
||||
$this->addReference($reference, $entry);
|
||||
}
|
||||
|
||||
@ -276,6 +276,17 @@ class Entry
|
||||
*/
|
||||
private $headers;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*
|
||||
* @Exclude
|
||||
*
|
||||
* @ORM\Column(name="is_not_parsed", type="boolean")
|
||||
*
|
||||
* @Groups({"entries_for_user", "export_all"})
|
||||
*/
|
||||
private $isNotParsed = false;
|
||||
|
||||
/**
|
||||
* @Exclude
|
||||
*
|
||||
@ -1006,4 +1017,28 @@ class Entry
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set isNotParsed.
|
||||
*
|
||||
* @param bool $isNotParsed
|
||||
*
|
||||
* @return Entry
|
||||
*/
|
||||
public function setNotParsed($isNotParsed)
|
||||
{
|
||||
$this->isNotParsed = $isNotParsed;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get isNotParsed.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isNotParsed()
|
||||
{
|
||||
return $this->isNotParsed;
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,6 +151,10 @@ class EntryFilterType extends AbstractType
|
||||
$qb->innerJoin('e.annotations', 'a');
|
||||
},
|
||||
])
|
||||
->add('isNotParsed', CheckboxFilterType::class, [
|
||||
'label' => 'entry.filters.parsed_label',
|
||||
'data' => $options['filter_parsed'],
|
||||
])
|
||||
->add('previewPicture', CheckboxFilterType::class, [
|
||||
'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
|
||||
if (false === $values['value']) {
|
||||
@ -198,6 +202,7 @@ class EntryFilterType extends AbstractType
|
||||
'filter_starred' => false,
|
||||
'filter_unread' => false,
|
||||
'filter_annotated' => false,
|
||||
'filter_parsed' => false,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,6 +260,7 @@ class ContentProxy
|
||||
|
||||
if (empty($content['html'])) {
|
||||
$content['html'] = $this->fetchingErrorMessage;
|
||||
$entry->setNotParsed(true);
|
||||
|
||||
if (!empty($content['description'])) {
|
||||
$content['html'] .= '<p><i>But we found a short description: </i></p>';
|
||||
|
||||
@ -207,14 +207,15 @@ class EntryRepository extends ServiceEntityRepository
|
||||
* @param string $order
|
||||
* @param int $since
|
||||
* @param string $tags
|
||||
* @param string $detail 'metadata' or 'full'. Include content field if 'full'
|
||||
* @param string $detail 'metadata' or 'full'. Include content field if 'full'
|
||||
* @param string $domainName
|
||||
* @param bool $isNotParsed
|
||||
*
|
||||
* @todo Breaking change: replace default detail=full by detail=metadata in a future version
|
||||
*
|
||||
* @return Pagerfanta
|
||||
*/
|
||||
public function findEntries($userId, $isArchived = null, $isStarred = null, $isPublic = null, $sort = 'created', $order = 'asc', $since = 0, $tags = '', $detail = 'full', $domainName = '')
|
||||
public function findEntries($userId, $isArchived = null, $isStarred = null, $isPublic = null, $sort = 'created', $order = 'asc', $since = 0, $tags = '', $detail = 'full', $domainName = '', $isNotParsed = null)
|
||||
{
|
||||
if (!\in_array(strtolower($detail), ['full', 'metadata'], true)) {
|
||||
throw new \Exception('Detail "' . $detail . '" parameter is wrong, allowed: full or metadata');
|
||||
@ -244,6 +245,10 @@ class EntryRepository extends ServiceEntityRepository
|
||||
$qb->andWhere('e.uid IS ' . (true === $isPublic ? 'NOT' : '') . ' NULL');
|
||||
}
|
||||
|
||||
if (null !== $isNotParsed) {
|
||||
$qb->andWhere('e.isNotParsed = :isNotParsed')->setParameter('isNotParsed', (bool) $isNotParsed);
|
||||
}
|
||||
|
||||
if ($since > 0) {
|
||||
$qb->andWhere('e.updatedAt > :since')->setParameter('since', new \DateTime(date('Y-m-d H:i:s', $since)));
|
||||
}
|
||||
@ -563,6 +568,24 @@ class EntryRepository extends ServiceEntityRepository
|
||||
return $qb->getQuery()->getArrayResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $userId
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function findAllEntriesIdByUserIdAndNotParsed($userId = null)
|
||||
{
|
||||
$qb = $this->createQueryBuilder('e')
|
||||
->select('e.id')
|
||||
->where('e.isNotParsed = true');
|
||||
|
||||
if (null !== $userId) {
|
||||
$qb->where('e.user = :userid')->setParameter(':userid', $userId);
|
||||
}
|
||||
|
||||
return $qb->getQuery()->getArrayResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all entries by url and owner.
|
||||
*
|
||||
|
||||
@ -138,7 +138,7 @@
|
||||
{{ form_label(form.isStarred) }}
|
||||
</div>
|
||||
|
||||
<div class="input-field col s6 with-checkbox">
|
||||
<div class="input-field col s12 with-checkbox">
|
||||
{{ form_widget(form.isUnread) }}
|
||||
{{ form_label(form.isUnread) }}
|
||||
</div>
|
||||
@ -148,6 +148,11 @@
|
||||
{{ form_label(form.isAnnotated) }}
|
||||
</div>
|
||||
|
||||
<div class="input-field col s12 with-checkbox">
|
||||
{{ form_widget(form.isNotParsed) }}
|
||||
{{ form_label(form.isNotParsed) }}
|
||||
</div>
|
||||
|
||||
<div class="col s12">
|
||||
<label>{{ 'entry.filters.preview_picture_help'|trans }}</label>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user