Skip to content

Commit

Permalink
Add Laravel Pail package and update job processes
Browse files Browse the repository at this point in the history
  • Loading branch information
ewilan-riviere committed Dec 23, 2023
1 parent bd95e78 commit 94d0979
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 4 deletions.
22 changes: 22 additions & 0 deletions .phpstorm.meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@
'Laravel\Fortify\Contracts\VerifyEmailResponse' => \Laravel\Fortify\Http\Responses\VerifyEmailResponse::class,
'Laravel\Fortify\Contracts\VerifyEmailViewResponse' => \Laravel\Fortify\Http\Responses\SimpleViewResponse::class,
'Laravel\Jetstream\Contracts\DeletesUsers' => \App\Actions\Jetstream\DeleteUser::class,
'Laravel\Pail\Files' => \Laravel\Pail\Files::class,
'Laravel\Pail\Handler' => \Laravel\Pail\Handler::class,
'Laravel\Scout\EngineManager' => \Laravel\Scout\EngineManager::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
Expand Down Expand Up @@ -499,6 +501,8 @@
'Laravel\Fortify\Contracts\VerifyEmailResponse' => \Laravel\Fortify\Http\Responses\VerifyEmailResponse::class,
'Laravel\Fortify\Contracts\VerifyEmailViewResponse' => \Laravel\Fortify\Http\Responses\SimpleViewResponse::class,
'Laravel\Jetstream\Contracts\DeletesUsers' => \App\Actions\Jetstream\DeleteUser::class,
'Laravel\Pail\Files' => \Laravel\Pail\Files::class,
'Laravel\Pail\Handler' => \Laravel\Pail\Handler::class,
'Laravel\Scout\EngineManager' => \Laravel\Scout\EngineManager::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
Expand Down Expand Up @@ -807,6 +811,8 @@
'Laravel\Fortify\Contracts\VerifyEmailResponse' => \Laravel\Fortify\Http\Responses\VerifyEmailResponse::class,
'Laravel\Fortify\Contracts\VerifyEmailViewResponse' => \Laravel\Fortify\Http\Responses\SimpleViewResponse::class,
'Laravel\Jetstream\Contracts\DeletesUsers' => \App\Actions\Jetstream\DeleteUser::class,
'Laravel\Pail\Files' => \Laravel\Pail\Files::class,
'Laravel\Pail\Handler' => \Laravel\Pail\Handler::class,
'Laravel\Scout\EngineManager' => \Laravel\Scout\EngineManager::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
Expand Down Expand Up @@ -1115,6 +1121,8 @@
'Laravel\Fortify\Contracts\VerifyEmailResponse' => \Laravel\Fortify\Http\Responses\VerifyEmailResponse::class,
'Laravel\Fortify\Contracts\VerifyEmailViewResponse' => \Laravel\Fortify\Http\Responses\SimpleViewResponse::class,
'Laravel\Jetstream\Contracts\DeletesUsers' => \App\Actions\Jetstream\DeleteUser::class,
'Laravel\Pail\Files' => \Laravel\Pail\Files::class,
'Laravel\Pail\Handler' => \Laravel\Pail\Handler::class,
'Laravel\Scout\EngineManager' => \Laravel\Scout\EngineManager::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
Expand Down Expand Up @@ -1423,6 +1431,8 @@
'Laravel\Fortify\Contracts\VerifyEmailResponse' => \Laravel\Fortify\Http\Responses\VerifyEmailResponse::class,
'Laravel\Fortify\Contracts\VerifyEmailViewResponse' => \Laravel\Fortify\Http\Responses\SimpleViewResponse::class,
'Laravel\Jetstream\Contracts\DeletesUsers' => \App\Actions\Jetstream\DeleteUser::class,
'Laravel\Pail\Files' => \Laravel\Pail\Files::class,
'Laravel\Pail\Handler' => \Laravel\Pail\Handler::class,
'Laravel\Scout\EngineManager' => \Laravel\Scout\EngineManager::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
Expand Down Expand Up @@ -1731,6 +1741,8 @@
'Laravel\Fortify\Contracts\VerifyEmailResponse' => \Laravel\Fortify\Http\Responses\VerifyEmailResponse::class,
'Laravel\Fortify\Contracts\VerifyEmailViewResponse' => \Laravel\Fortify\Http\Responses\SimpleViewResponse::class,
'Laravel\Jetstream\Contracts\DeletesUsers' => \App\Actions\Jetstream\DeleteUser::class,
'Laravel\Pail\Files' => \Laravel\Pail\Files::class,
'Laravel\Pail\Handler' => \Laravel\Pail\Handler::class,
'Laravel\Scout\EngineManager' => \Laravel\Scout\EngineManager::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
Expand Down Expand Up @@ -2039,6 +2051,8 @@
'Laravel\Fortify\Contracts\VerifyEmailResponse' => \Laravel\Fortify\Http\Responses\VerifyEmailResponse::class,
'Laravel\Fortify\Contracts\VerifyEmailViewResponse' => \Laravel\Fortify\Http\Responses\SimpleViewResponse::class,
'Laravel\Jetstream\Contracts\DeletesUsers' => \App\Actions\Jetstream\DeleteUser::class,
'Laravel\Pail\Files' => \Laravel\Pail\Files::class,
'Laravel\Pail\Handler' => \Laravel\Pail\Handler::class,
'Laravel\Scout\EngineManager' => \Laravel\Scout\EngineManager::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
Expand Down Expand Up @@ -2347,6 +2361,8 @@
'Laravel\Fortify\Contracts\VerifyEmailResponse' => \Laravel\Fortify\Http\Responses\VerifyEmailResponse::class,
'Laravel\Fortify\Contracts\VerifyEmailViewResponse' => \Laravel\Fortify\Http\Responses\SimpleViewResponse::class,
'Laravel\Jetstream\Contracts\DeletesUsers' => \App\Actions\Jetstream\DeleteUser::class,
'Laravel\Pail\Files' => \Laravel\Pail\Files::class,
'Laravel\Pail\Handler' => \Laravel\Pail\Handler::class,
'Laravel\Scout\EngineManager' => \Laravel\Scout\EngineManager::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
Expand Down Expand Up @@ -2655,6 +2671,8 @@
'Laravel\Fortify\Contracts\VerifyEmailResponse' => \Laravel\Fortify\Http\Responses\VerifyEmailResponse::class,
'Laravel\Fortify\Contracts\VerifyEmailViewResponse' => \Laravel\Fortify\Http\Responses\SimpleViewResponse::class,
'Laravel\Jetstream\Contracts\DeletesUsers' => \App\Actions\Jetstream\DeleteUser::class,
'Laravel\Pail\Files' => \Laravel\Pail\Files::class,
'Laravel\Pail\Handler' => \Laravel\Pail\Handler::class,
'Laravel\Scout\EngineManager' => \Laravel\Scout\EngineManager::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
Expand Down Expand Up @@ -2963,6 +2981,8 @@
'Laravel\Fortify\Contracts\VerifyEmailResponse' => \Laravel\Fortify\Http\Responses\VerifyEmailResponse::class,
'Laravel\Fortify\Contracts\VerifyEmailViewResponse' => \Laravel\Fortify\Http\Responses\SimpleViewResponse::class,
'Laravel\Jetstream\Contracts\DeletesUsers' => \App\Actions\Jetstream\DeleteUser::class,
'Laravel\Pail\Files' => \Laravel\Pail\Files::class,
'Laravel\Pail\Handler' => \Laravel\Pail\Handler::class,
'Laravel\Scout\EngineManager' => \Laravel\Scout\EngineManager::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
Expand Down Expand Up @@ -3271,6 +3291,8 @@
'Laravel\Fortify\Contracts\VerifyEmailResponse' => \Laravel\Fortify\Http\Responses\VerifyEmailResponse::class,
'Laravel\Fortify\Contracts\VerifyEmailViewResponse' => \Laravel\Fortify\Http\Responses\SimpleViewResponse::class,
'Laravel\Jetstream\Contracts\DeletesUsers' => \App\Actions\Jetstream\DeleteUser::class,
'Laravel\Pail\Files' => \Laravel\Pail\Files::class,
'Laravel\Pail\Handler' => \Laravel\Pail\Handler::class,
'Laravel\Scout\EngineManager' => \Laravel\Scout\EngineManager::class,
'Laravel\Telescope\Contracts\ClearableRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
'Laravel\Telescope\Contracts\EntriesRepository' => \Laravel\Telescope\Storage\DatabaseEntriesRepository::class,
Expand Down
8 changes: 8 additions & 0 deletions app/Console/Commands/Bookshelves/MakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Log;
use Kiwilan\Steward\Commands\Commandable;
use Spatie\Tags\Tag;

Expand Down Expand Up @@ -132,7 +133,11 @@ private function setupOptions()
$parser = BookFilesReader::make(limit: $this->limit);
$this->files = $parser->items();

Log::info('Files detected: '.count($this->files));

if ($this->fresh) {
Log::info('Fresh mode enabled, delete all books and relations');

MediaExtended::query()->where('collection_name', MediaDiskEnum::cover)->delete();

foreach (BookFormatEnum::toArray() as $format) {
Expand All @@ -154,6 +159,7 @@ private function setupOptions()

private function setGenres()
{
Log::info('Set genres');
$genres = config('bookshelves.tags.genres_list');

foreach ($genres as $genre) {
Expand All @@ -164,12 +170,14 @@ private function setGenres()
private function convert(BookFileReader $file): void
{
if ($this->fresh) {
Log::info("Parse file: {$file->path()}");
BookParserProcess::dispatch($file, $this->verbose, $this->default);

return;
}

if (! in_array($file->path(), $this->books, true)) {
Log::info("Parse file: {$file->path()}");
BookParserProcess::dispatch($file, $this->verbose, $this->default);
}
}
Expand Down
7 changes: 6 additions & 1 deletion app/Jobs/BookParserProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ public function __construct(
*/
public function handle(): void
{
BookEngine::make($this->file, $this->verbose, $this->default);
$engine = BookEngine::make($this->file, $this->verbose, $this->default);
$title = $engine->ebook()->getTitle();
if (! $title) {
$title = $this->file->path();
}
Log::info("BookParserProcess: {$title}");
}

private function createLog(string $message, bool $success = false): void
Expand Down
3 changes: 3 additions & 0 deletions app/Jobs/BookRelationsParserProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;

class BookRelationsParserProcess implements ShouldQueue
{
Expand All @@ -35,6 +36,8 @@ public function handle(): void

private function parseRelation(string $model)
{
Log::info("BookRelationsParserProcess: {$model}");

/** @var Serie|Author $entity */
foreach ($model::all() as $entity) {
EntityConverter::make($entity)
Expand Down
8 changes: 6 additions & 2 deletions app/Jobs/GoogleBookProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Kiwilan\HttpPool\Utils\PrintConsole;
use Kiwilan\Steward\Services\GoogleBook\GoogleBookable;
use Kiwilan\Steward\Services\GoogleBookService;
Expand All @@ -29,14 +30,16 @@ public function __construct(
*/
public function handle(): void
{
Log::info('GoogleBookProcess');

$books = Book::all();
$service = GoogleBookService::make($books)
->setIsbnFields(['isbn13', 'isbn10'])
->setDebug($this->verbose);

$console = PrintConsole::make();
$count = $service->getCount();
$booksCount = Book::count();
$booksCount = Book::query()->count();
$isbn_types = implode('/', ['isbn13', 'isbn10']);
$console->print("Need to have {$isbn_types}, on {$booksCount} entities, {$count} entities can be scanned.");

Expand All @@ -52,7 +55,8 @@ public function handle(): void
// $bar = $this->output->createProgressBar(count($service->items()));

foreach ($service->getItems() as $id => $item) {
$model = Book::find($id);
Log::info("GoogleBookProcess: {$id}");
$model = Book::query()->find($id);

if ($model instanceof GoogleBookable) {
$model->googleBookConvert($item);
Expand Down
6 changes: 6 additions & 0 deletions app/Jobs/WikipediaProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Kiwilan\HttpPool\Utils\PrintConsole;
use Kiwilan\Steward\Services\ClassParser\MetaClassItem;
use Kiwilan\Steward\Services\Wikipedia\Wikipediable;
Expand All @@ -33,6 +34,8 @@ public function __construct(
*/
public function handle(): void
{
Log::info('WikipediaProcess');

if ($this->authors) {
$this->wikipediaRequest(
Author::class,
Expand All @@ -59,6 +62,8 @@ public function handle(): void
*/
private function wikipediaRequest(string $className, array $attributes, ?array $precision = null): int
{
Log::info("WikipediaProcess: {$className}");

$meta = MetaClassItem::make($className);
$console = PrintConsole::make();

Expand Down Expand Up @@ -86,6 +91,7 @@ private function wikipediaRequest(string $className, array $attributes, ?array $
// $bar = $this->output->createProgressBar(count($service->items()));

foreach ($service->getItems() as $id => $item) {
Log::info("WikipediaProcess: {$id}");
$model = $className::find($id);

if ($model instanceof Wikipediable) {
Expand Down
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"kiwilan/typescriptable-laravel": "^1.11",
"laravel/framework": "^10.0",
"laravel/jetstream": "^4.0",
"laravel/pail": "^1.0",
"laravel/sanctum": "^3.2",
"laravel/scout": "^10.0",
"laravel/telescope": "^4.15",
Expand Down Expand Up @@ -135,6 +136,10 @@
"insights": [
"php artisan insights --ansi --no-interaction"
],
"pail": [
"Composer\\Config::disableProcessTimeout",
"php artisan pail -v"
],
"serve": [
"Composer\\Config::disableProcessTimeout",
"php artisan serve"
Expand Down
79 changes: 78 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 94d0979

Please sign in to comment.