mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Fixed some mis-refactoring and split search service
Search service broken into index and runner tools.
This commit is contained in:
@ -21,7 +21,7 @@ $factory->define(\BookStack\Auth\User::class, function ($faker) {
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\BookStack\Entities\Bookshelf::class, function ($faker) {
|
||||
$factory->define(\BookStack\Entities\Models\Bookshelf::class, function ($faker) {
|
||||
return [
|
||||
'name' => $faker->sentence,
|
||||
'slug' => Str::random(10),
|
||||
@ -29,7 +29,7 @@ $factory->define(\BookStack\Entities\Bookshelf::class, function ($faker) {
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\BookStack\Entities\Book::class, function ($faker) {
|
||||
$factory->define(\BookStack\Entities\Models\Book::class, function ($faker) {
|
||||
return [
|
||||
'name' => $faker->sentence,
|
||||
'slug' => Str::random(10),
|
||||
@ -37,7 +37,7 @@ $factory->define(\BookStack\Entities\Book::class, function ($faker) {
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\BookStack\Entities\Chapter::class, function ($faker) {
|
||||
$factory->define(\BookStack\Entities\Models\Chapter::class, function ($faker) {
|
||||
return [
|
||||
'name' => $faker->sentence,
|
||||
'slug' => Str::random(10),
|
||||
@ -45,7 +45,7 @@ $factory->define(\BookStack\Entities\Chapter::class, function ($faker) {
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\BookStack\Entities\Page::class, function ($faker) {
|
||||
$factory->define(\BookStack\Entities\Models\Page::class, function ($faker) {
|
||||
$html = '<p>' . implode('</p>', $faker->paragraphs(5)) . '</p>';
|
||||
return [
|
||||
'name' => $faker->sentence,
|
||||
|
@ -119,11 +119,11 @@ class CreateBookshelvesTable extends Migration
|
||||
Schema::dropIfExists('bookshelves');
|
||||
|
||||
// Drop related polymorphic items
|
||||
DB::table('activities')->where('entity_type', '=', 'BookStack\Entities\Bookshelf')->delete();
|
||||
DB::table('views')->where('viewable_type', '=', 'BookStack\Entities\Bookshelf')->delete();
|
||||
DB::table('entity_permissions')->where('restrictable_type', '=', 'BookStack\Entities\Bookshelf')->delete();
|
||||
DB::table('tags')->where('entity_type', '=', 'BookStack\Entities\Bookshelf')->delete();
|
||||
DB::table('search_terms')->where('entity_type', '=', 'BookStack\Entities\Bookshelf')->delete();
|
||||
DB::table('comments')->where('entity_type', '=', 'BookStack\Entities\Bookshelf')->delete();
|
||||
DB::table('activities')->where('entity_type', '=', 'BookStack\Entities\Models\Bookshelf')->delete();
|
||||
DB::table('views')->where('viewable_type', '=', 'BookStack\Entities\Models\Bookshelf')->delete();
|
||||
DB::table('entity_permissions')->where('restrictable_type', '=', 'BookStack\Entities\Models\Bookshelf')->delete();
|
||||
DB::table('tags')->where('entity_type', '=', 'BookStack\Entities\Models\Bookshelf')->delete();
|
||||
DB::table('search_terms')->where('entity_type', '=', 'BookStack\Entities\Models\Bookshelf')->delete();
|
||||
DB::table('comments')->where('entity_type', '=', 'BookStack\Entities\Models\Bookshelf')->delete();
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ use BookStack\Auth\Permissions\PermissionService;
|
||||
use BookStack\Auth\Permissions\RolePermission;
|
||||
use BookStack\Auth\Role;
|
||||
use BookStack\Auth\User;
|
||||
use BookStack\Entities\Bookshelf;
|
||||
use BookStack\Entities\Chapter;
|
||||
use BookStack\Entities\Page;
|
||||
use BookStack\Entities\SearchService;
|
||||
use BookStack\Entities\Models\Bookshelf;
|
||||
use BookStack\Entities\Models\Chapter;
|
||||
use BookStack\Entities\Models\Page;
|
||||
use BookStack\Entities\Tools\SearchIndex;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@ -33,7 +33,7 @@ class DummyContentSeeder extends Seeder
|
||||
|
||||
$byData = ['created_by' => $editorUser->id, 'updated_by' => $editorUser->id];
|
||||
|
||||
factory(\BookStack\Entities\Book::class, 5)->create($byData)
|
||||
factory(\BookStack\Entities\Models\Book::class, 5)->create($byData)
|
||||
->each(function($book) use ($editorUser, $byData) {
|
||||
$chapters = factory(Chapter::class, 3)->create($byData)
|
||||
->each(function($chapter) use ($editorUser, $book, $byData){
|
||||
@ -45,7 +45,7 @@ class DummyContentSeeder extends Seeder
|
||||
$book->pages()->saveMany($pages);
|
||||
});
|
||||
|
||||
$largeBook = factory(\BookStack\Entities\Book::class)->create(array_merge($byData, ['name' => 'Large book' . Str::random(10)]));
|
||||
$largeBook = factory(\BookStack\Entities\Models\Book::class)->create(array_merge($byData, ['name' => 'Large book' . Str::random(10)]));
|
||||
$pages = factory(Page::class, 200)->make($byData);
|
||||
$chapters = factory(Chapter::class, 50)->make($byData);
|
||||
$largeBook->pages()->saveMany($pages);
|
||||
@ -67,6 +67,6 @@ class DummyContentSeeder extends Seeder
|
||||
$token->save();
|
||||
|
||||
app(PermissionService::class)->buildJointPermissions();
|
||||
app(SearchService::class)->indexAllEntities();
|
||||
app(SearchIndex::class)->indexAllEntities();
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,9 @@
|
||||
use BookStack\Auth\Permissions\PermissionService;
|
||||
use BookStack\Auth\Role;
|
||||
use BookStack\Auth\User;
|
||||
use BookStack\Entities\Chapter;
|
||||
use BookStack\Entities\Page;
|
||||
use BookStack\Entities\SearchService;
|
||||
use BookStack\Entities\Models\Chapter;
|
||||
use BookStack\Entities\Models\Page;
|
||||
use BookStack\Entities\Tools\SearchIndex;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@ -23,12 +23,12 @@ class LargeContentSeeder extends Seeder
|
||||
$editorRole = Role::getRole('editor');
|
||||
$editorUser->attachRole($editorRole);
|
||||
|
||||
$largeBook = factory(\BookStack\Entities\Book::class)->create(['name' => 'Large book' . Str::random(10), 'created_by' => $editorUser->id, 'updated_by' => $editorUser->id]);
|
||||
$largeBook = factory(\BookStack\Entities\Models\Book::class)->create(['name' => 'Large book' . Str::random(10), 'created_by' => $editorUser->id, 'updated_by' => $editorUser->id]);
|
||||
$pages = factory(Page::class, 200)->make(['created_by' => $editorUser->id, 'updated_by' => $editorUser->id]);
|
||||
$chapters = factory(Chapter::class, 50)->make(['created_by' => $editorUser->id, 'updated_by' => $editorUser->id]);
|
||||
$largeBook->pages()->saveMany($pages);
|
||||
$largeBook->chapters()->saveMany($chapters);
|
||||
app(PermissionService::class)->buildJointPermissions();
|
||||
app(SearchService::class)->indexAllEntities();
|
||||
app(SearchIndex::class)->indexAllEntities();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user