mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 14:18:27 +01:00
Enh: On search index rebuilding - use batch queries
This commit is contained in:
parent
dd648946ae
commit
9a90d5dc15
@ -13,6 +13,7 @@ HumHub Change Log
|
|||||||
- Fix #2571: last_login not set after registration direct login
|
- Fix #2571: last_login not set after registration direct login
|
||||||
- Enh: Always trigger dom widget events for widget `fire` until `triggerDom` is set to false
|
- Enh: Always trigger dom widget events for widget `fire` until `triggerDom` is set to false
|
||||||
- Enh: Added `richtextPaste` event
|
- Enh: Added `richtextPaste` event
|
||||||
|
- Enh: On search index rebuilding - use batch queries
|
||||||
|
|
||||||
1.2.0 (April 16, 2017)
|
1.2.0 (April 16, 2017)
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
@ -11,7 +11,6 @@ namespace humhub\modules\content;
|
|||||||
use Yii;
|
use Yii;
|
||||||
use humhub\modules\content\models\Content;
|
use humhub\modules\content\models\Content;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Events provides callbacks to handle events.
|
* Events provides callbacks to handle events.
|
||||||
*
|
*
|
||||||
@ -76,7 +75,7 @@ class Events extends \yii\base\Object
|
|||||||
$stackWidget->addWidget(widgets\DeleteLink::className(), ['content' => $content], ['sortOrder' => 100]);
|
$stackWidget->addWidget(widgets\DeleteLink::className(), ['content' => $content], ['sortOrder' => 100]);
|
||||||
$stackWidget->addWidget(widgets\VisibilityLink::className(), ['contentRecord' => $content], ['sortOrder' => 250]);
|
$stackWidget->addWidget(widgets\VisibilityLink::className(), ['contentRecord' => $content], ['sortOrder' => 250]);
|
||||||
$stackWidget->addWidget(widgets\NotificationSwitchLink::className(), ['content' => $content], ['sortOrder' => 300]);
|
$stackWidget->addWidget(widgets\NotificationSwitchLink::className(), ['content' => $content], ['sortOrder' => 300]);
|
||||||
$stackWidget->addWidget(widgets\PermaLink::className(), ['content' => $content], ['sortOrder' => 400] );
|
$stackWidget->addWidget(widgets\PermaLink::className(), ['content' => $content], ['sortOrder' => 400]);
|
||||||
$stackWidget->addWidget(widgets\PinLink::className(), ['content' => $content], ['sortOrder' => 500]);
|
$stackWidget->addWidget(widgets\PinLink::className(), ['content' => $content], ['sortOrder' => 500]);
|
||||||
$stackWidget->addWidget(widgets\ArchiveLink::className(), ['content' => $content], ['sortOrder' => 600]);
|
$stackWidget->addWidget(widgets\ArchiveLink::className(), ['content' => $content], ['sortOrder' => 600]);
|
||||||
}
|
}
|
||||||
@ -103,10 +102,12 @@ class Events extends \yii\base\Object
|
|||||||
*/
|
*/
|
||||||
public static function onSearchRebuild($event)
|
public static function onSearchRebuild($event)
|
||||||
{
|
{
|
||||||
foreach (Content::find()->all() as $content) {
|
foreach (Content::find()->batch() as $contents) {
|
||||||
$contentObject = $content->getPolymorphicRelation();
|
foreach ($contents as $content) {
|
||||||
if ($contentObject instanceof \humhub\modules\search\interfaces\Searchable) {
|
$contentObject = $content->getPolymorphicRelation();
|
||||||
Yii::$app->search->add($contentObject);
|
if ($contentObject instanceof \humhub\modules\search\interfaces\Searchable) {
|
||||||
|
Yii::$app->search->add($contentObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,10 @@ class Events extends \yii\base\Object
|
|||||||
*/
|
*/
|
||||||
public static function onSearchRebuild($event)
|
public static function onSearchRebuild($event)
|
||||||
{
|
{
|
||||||
foreach (Space::find()->all() as $obj) {
|
foreach (Space::find()->batch() as $spaces) {
|
||||||
Yii::$app->search->add($obj);
|
foreach ($spaces as $space) {
|
||||||
|
Yii::$app->search->add($space);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace humhub\modules\user;
|
namespace humhub\modules\user;
|
||||||
|
|
||||||
use humhub\modules\content\models\ContentContainer;
|
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use humhub\modules\content\models\ContentContainer;
|
||||||
use humhub\modules\user\models\User;
|
use humhub\modules\user\models\User;
|
||||||
use humhub\modules\user\models\Password;
|
use humhub\modules\user\models\Password;
|
||||||
use humhub\modules\user\models\Profile;
|
use humhub\modules\user\models\Profile;
|
||||||
@ -26,8 +26,10 @@ class Events extends \yii\base\Object
|
|||||||
*/
|
*/
|
||||||
public static function onSearchRebuild($event)
|
public static function onSearchRebuild($event)
|
||||||
{
|
{
|
||||||
foreach (models\User::find()->active()->all() as $obj) {
|
foreach (models\User::find()->active()->batch() as $users) {
|
||||||
\Yii::$app->search->add($obj);
|
foreach ($users as $user) {
|
||||||
|
Yii::$app->search->add($user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user