Change flash message for queued articles

This commit is contained in:
Jeremy Benoist 2016-09-13 21:09:05 +02:00
parent e01a3c98d6
commit c80cc01afa
No known key found for this signature in database
GPG Key ID: BCA73962457ACC3C
22 changed files with 65 additions and 56 deletions

View File

@ -430,6 +430,7 @@ flashes:
# failed: 'Import failed, please try again.'
# failed_on_file: 'Error while processing import. Please verify your import file.'
# summary: 'Import summary: %imported% imported, %skipped% already saved.'
# summary_with_queue: 'Import summary: %queued% queued.'
developer:
notice:
# client_created: 'New client created.'

View File

@ -430,6 +430,7 @@ flashes:
failed: 'Import fehlgeschlagen, bitte erneut probieren.'
failed_on_file: 'Fehler während des Imports. Bitte überprüfe deine Import-Datei.'
summary: 'Import-Zusammenfassung: %imported% importiert, %skipped% bereits gespeichert.'
# summary_with_queue: 'Import summary: %queued% queued.'
developer:
notice:
client_created: 'Neuer Client erstellt.'

View File

@ -432,6 +432,7 @@ flashes:
failed: 'Import failed, please try again.'
failed_on_file: 'Error while processing import. Please verify your import file.'
summary: 'Import summary: %imported% imported, %skipped% already saved.'
summary_with_queue: 'Import summary: %queued% queued.'
developer:
notice:
client_created: 'New client %name% created.'

View File

@ -427,9 +427,10 @@ flashes:
tag_added: 'Etiqueta añadida'
import:
notice:
failed: 'Importación reprobada, por favor inténtelo de nuevo.'
failed_on_file: 'Se ocurre un error por procesar importación. Por favor verifique su archivo importado.'
summary: 'Resúmen importado: %importado% importado, %saltados% ya guardado.'
failed: 'Importación reprobada, por favor inténtelo de nuevo.'
failed_on_file: 'Se ocurre un error por procesar importación. Por favor verifique su archivo importado.'
summary: 'Resúmen importado: %importado% importado, %saltados% ya guardado.'
# summary_with_queue: 'Import summary: %queued% queued.'
developer:
notice:
client_created: 'Nuevo cliente creado.'

View File

@ -430,6 +430,7 @@ flashes:
failed: 'درون‌ریزی شکست خورد. لطفاً دوباره تلاش کنید.'
failed_on_file: 'خطا هنگام پردازش پروندهٔ ورودی. آیا پروندهٔ درون‌ریزی شده سالم است؟'
summary: 'گزارش درون‌ریزی: %imported% وارد شد, %skipped% از قبل ذخیره شده بود.'
# summary_with_queue: 'Import summary: %queued% queued.'
developer:
notice:
# client_created: 'New client created.'

View File

@ -432,6 +432,7 @@ flashes:
failed: "L'import a échoué, veuillez ré-essayer"
failed_on_file: "Erreur lors du traitement de l'import. Vérifier votre fichier."
summary: "Rapport d'import: %imported% importés, %skipped% déjà présent."
summary_with_queue: "Rapport d'import: %queued% en cours de traitement."
developer:
notice:
client_created: 'Nouveau client %name% créé'

View File

@ -429,6 +429,7 @@ flashes:
failed: 'Importazione fallita, riprova.'
failed_on_file: 'Errore durante la processazione dei dati da importare. Verifica il tuo file di import.'
summary: 'Sommario di importazione: %imported% importati, %skipped% già salvati.'
# summary_with_queue: 'Import summary: %queued% queued.'
developer:
notice:
client_created: 'Nuovo client creato.'

View File

@ -430,6 +430,7 @@ flashes:
failed: "L'importacion a fracassat, mercés de tornar ensajar"
failed_on_file: "Errorr pendent du tractament de l'import. Mercés de verificar vòstre fichièr."
summary: "Rapòrt d'import: %imported% importats, %skipped% ja presents."
# summary_with_queue: 'Import summary: %queued% queued.'
developer:
notice:
client_created: 'Novèl client creat'

View File

@ -430,6 +430,7 @@ flashes:
failed: 'Nieudany import, prosimy spróbować ponownie.'
failed_on_file: 'Błąd podczas ptrzetwarzania pliku. Sprawdż swój importowany plik.'
summary: 'Podsumowanie importu: %imported% zaimportowane, %skipped% już zapisane.'
# summary_with_queue: 'Import summary: %queued% queued.'
developer:
notice:
client_created: 'Nowy klient utworzony.'

View File

@ -430,6 +430,7 @@ flashes:
# failed: 'Import failed, please try again.'
# failed_on_file: 'Error while processing import. Please verify your import file.'
# summary: 'Import summary: %imported% imported, %skipped% already saved.'
# summary_with_queue: 'Import summary: %queued% queued.'
developer:
notice:
# client_created: 'New client created.'

View File

@ -430,6 +430,7 @@ flashes:
# failed: 'Import failed, please try again.'
# failed_on_file: 'Error while processing import. Please verify your import file.'
# summary: 'Import summary: %imported% imported, %skipped% already saved.'
# summary_with_queue: 'Import summary: %queued% queued.'
developer:
notice:
# client_created: 'New client created.'

View File

@ -102,6 +102,12 @@ class PocketController extends Controller
'%imported%' => $summary['imported'],
'%skipped%' => $summary['skipped'],
]);
if (0 < $summary['queued']) {
$message = $this->get('translator')->trans('flashes.import.notice.summary_with_queue', [
'%queued%' => $summary['queued'],
]);
}
}
$this->get('session')->getFlashBag()->add(

View File

@ -46,6 +46,12 @@ class ReadabilityController extends Controller
'%skipped%' => $summary['skipped'],
]);
if (0 < $summary['queued']) {
$message = $this->get('translator')->trans('flashes.import.notice.summary_with_queue', [
'%queued%' => $summary['queued'],
]);
}
unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name);
}

View File

@ -60,6 +60,12 @@ abstract class WallabagController extends Controller
'%skipped%' => $summary['skipped'],
]);
if (0 < $summary['queued']) {
$message = $this->get('translator')->trans('flashes.import.notice.summary_with_queue', [
'%queued%' => $summary['queued'],
]);
}
unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name);
}

View File

@ -21,6 +21,7 @@ abstract class AbstractImport implements ImportInterface
protected $markAsRead;
protected $skippedEntries = 0;
protected $importedEntries = 0;
protected $queuedEntries = 0;
public function __construct(EntityManager $em, ContentProxy $contentProxy)
{
@ -145,12 +146,24 @@ abstract class AbstractImport implements ImportInterface
$importedEntry = $this->setEntryAsRead($importedEntry);
}
++$this->importedEntries;
++$this->queuedEntries;
$this->producer->publish(json_encode($importedEntry));
}
}
/**
* {@inheritdoc}
*/
public function getSummary()
{
return [
'skipped' => $this->skippedEntries,
'imported' => $this->importedEntries,
'queued' => $this->queuedEntries,
];
}
/**
* Parse one entry.
*

View File

@ -172,17 +172,6 @@ class PocketImport extends AbstractImport
return true;
}
/**
* {@inheritdoc}
*/
public function getSummary()
{
return [
'skipped' => $this->skippedEntries,
'imported' => $this->importedEntries,
];
}
/**
* Set the Guzzle client.
*

View File

@ -44,17 +44,6 @@ class ReadabilityImport extends AbstractImport
return $this;
}
/**
* {@inheritdoc}
*/
public function getSummary()
{
return [
'skipped' => $this->skippedEntries,
'imported' => $this->importedEntries,
];
}
/**
* {@inheritdoc}
*/

View File

@ -72,17 +72,6 @@ abstract class WallabagImport extends AbstractImport
return true;
}
/**
* {@inheritdoc}
*/
public function getSummary()
{
return [
'skipped' => $this->skippedEntries,
'imported' => $this->importedEntries,
];
}
/**
* Set file path to the json file.
*

View File

@ -270,7 +270,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
$res = $pocketImport->import();
$this->assertTrue($res);
$this->assertEquals(['skipped' => 1, 'imported' => 1], $pocketImport->getSummary());
$this->assertEquals(['skipped' => 1, 'imported' => 1, 'queued' => 0], $pocketImport->getSummary());
}
/**
@ -365,7 +365,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
$res = $pocketImport->setMarkAsRead(true)->import();
$this->assertTrue($res);
$this->assertEquals(['skipped' => 0, 'imported' => 2], $pocketImport->getSummary());
$this->assertEquals(['skipped' => 0, 'imported' => 2, 'queued' => 0], $pocketImport->getSummary());
}
/**
@ -451,7 +451,7 @@ JSON;
$res = $pocketImport->setMarkAsRead(true)->import();
$this->assertTrue($res);
$this->assertEquals(['skipped' => 0, 'imported' => 1], $pocketImport->getSummary());
$this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $pocketImport->getSummary());
}
/**
@ -530,7 +530,7 @@ JSON;
$res = $pocketImport->setMarkAsRead(true)->import();
$this->assertTrue($res);
$this->assertEquals(['skipped' => 0, 'imported' => 1], $pocketImport->getSummary());
$this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $pocketImport->getSummary());
$this->assertNotEmpty($redisMock->lpop('pocket'));
}
@ -607,6 +607,6 @@ JSON;
$res = $pocketImport->import();
$this->assertTrue($res);
$this->assertEquals(['skipped' => 1, 'imported' => 0], $pocketImport->getSummary());
$this->assertEquals(['skipped' => 1, 'imported' => 0, 'queued' => 0], $pocketImport->getSummary());
}
}

View File

@ -82,7 +82,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
$res = $readabilityImport->import();
$this->assertTrue($res);
$this->assertEquals(['skipped' => 0, 'imported' => 24], $readabilityImport->getSummary());
$this->assertEquals(['skipped' => 0, 'imported' => 24, 'queued' => 0], $readabilityImport->getSummary());
}
public function testImportAndMarkAllAsRead()
@ -120,7 +120,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($res);
$this->assertEquals(['skipped' => 1, 'imported' => 1], $readabilityImport->getSummary());
$this->assertEquals(['skipped' => 1, 'imported' => 1, 'queued' => 0], $readabilityImport->getSummary());
}
public function testImportWithRabbit()
@ -160,7 +160,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
$res = $readabilityImport->setMarkAsRead(true)->import();
$this->assertTrue($res);
$this->assertEquals(['skipped' => 0, 'imported' => 24], $readabilityImport->getSummary());
$this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 24], $readabilityImport->getSummary());
}
public function testImportWithRedis()
@ -198,7 +198,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
$res = $readabilityImport->setMarkAsRead(true)->import();
$this->assertTrue($res);
$this->assertEquals(['skipped' => 0, 'imported' => 24], $readabilityImport->getSummary());
$this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 24], $readabilityImport->getSummary());
$this->assertNotEmpty($redisMock->lpop('readability'));
}

View File

@ -82,7 +82,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
$res = $wallabagV1Import->import();
$this->assertTrue($res);
$this->assertEquals(['skipped' => 1, 'imported' => 3], $wallabagV1Import->getSummary());
$this->assertEquals(['skipped' => 1, 'imported' => 3, 'queued' => 0], $wallabagV1Import->getSummary());
}
public function testImportAndMarkAllAsRead()
@ -120,7 +120,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($res);
$this->assertEquals(['skipped' => 0, 'imported' => 3], $wallabagV1Import->getSummary());
$this->assertEquals(['skipped' => 0, 'imported' => 3, 'queued' => 0], $wallabagV1Import->getSummary());
}
public function testImportWithRabbit()
@ -160,7 +160,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
$res = $wallabagV1Import->setMarkAsRead(true)->import();
$this->assertTrue($res);
$this->assertEquals(['skipped' => 0, 'imported' => 4], $wallabagV1Import->getSummary());
$this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $wallabagV1Import->getSummary());
}
public function testImportWithRedis()
@ -198,7 +198,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
$res = $wallabagV1Import->setMarkAsRead(true)->import();
$this->assertTrue($res);
$this->assertEquals(['skipped' => 0, 'imported' => 4], $wallabagV1Import->getSummary());
$this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $wallabagV1Import->getSummary());
$this->assertNotEmpty($redisMock->lpop('wallabag_v1'));
}

View File

@ -78,7 +78,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
$res = $wallabagV2Import->import();
$this->assertTrue($res);
$this->assertEquals(['skipped' => 22, 'imported' => 2], $wallabagV2Import->getSummary());
$this->assertEquals(['skipped' => 22, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary());
}
public function testImportAndMarkAllAsRead()
@ -116,7 +116,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($res);
$this->assertEquals(['skipped' => 0, 'imported' => 2], $wallabagV2Import->getSummary());
$this->assertEquals(['skipped' => 0, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary());
}
public function testImportWithRabbit()
@ -152,7 +152,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
$res = $wallabagV2Import->setMarkAsRead(true)->import();
$this->assertTrue($res);
$this->assertEquals(['skipped' => 0, 'imported' => 24], $wallabagV2Import->getSummary());
$this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 24], $wallabagV2Import->getSummary());
}
public function testImportWithRedis()
@ -186,7 +186,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
$res = $wallabagV2Import->setMarkAsRead(true)->import();
$this->assertTrue($res);
$this->assertEquals(['skipped' => 0, 'imported' => 24], $wallabagV2Import->getSummary());
$this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 24], $wallabagV2Import->getSummary());
$this->assertNotEmpty($redisMock->lpop('wallabag_v2'));
}
@ -227,7 +227,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
$res = $wallabagV2Import->import();
$this->assertFalse($res);
$this->assertEquals(['skipped' => 0, 'imported' => 0], $wallabagV2Import->getSummary());
$this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 0], $wallabagV2Import->getSummary());
}
public function testImportWithExceptionFromGraby()
@ -256,6 +256,6 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
$res = $wallabagV2Import->import();
$this->assertTrue($res);
$this->assertEquals(['skipped' => 24, 'imported' => 0], $wallabagV2Import->getSummary());
$this->assertEquals(['skipped' => 24, 'imported' => 0, 'queued' => 0], $wallabagV2Import->getSummary());
}
}