diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 5db73bb3e..bbce42d64 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -16,6 +16,7 @@ use OCA\Activity\Data; use OCA\Activity\FilesHooksStatic; use OCA\Activity\GroupHelper; +use OCA\Activity\Listener\AddMissingIndicesListener; use OCA\Activity\Listener\LoadSidebarScripts; use OCA\Activity\Listener\SetUserDefaults; use OCA\Activity\Listener\ShareEventListener; @@ -29,6 +30,7 @@ use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; +use OCP\DB\Events\AddMissingIndicesEvent; use OCP\IConfig; use OCP\IDateTimeFormatter; use OCP\IDBConnection; @@ -127,6 +129,7 @@ public function register(IRegistrationContext $context): void { }, false); $context->registerCapability(Capabilities::class); + $context->registerEventListener(AddMissingIndicesEvent::class, AddMissingIndicesListener::class); $context->registerEventListener(LoadSidebar::class, LoadSidebarScripts::class); $context->registerEventListener(UserDeletedEvent::class, UserDeleted::class); $context->registerEventListener(PostLoginEvent::class, SetUserDefaults::class); diff --git a/lib/Listener/AddMissingIndicesListener.php b/lib/Listener/AddMissingIndicesListener.php new file mode 100644 index 000000000..aa2008466 --- /dev/null +++ b/lib/Listener/AddMissingIndicesListener.php @@ -0,0 +1,34 @@ + + */ +class AddMissingIndicesListener implements IEventListener { + #[\Override] + + public function handle(Event $event): void { + if (!($event instanceof AddMissingIndicesEvent)) { + return; + } + + $event->replaceIndex( + 'activity', + ['activity_object'], + 'activity_object_user', + ['affecteduser', 'object_type', 'object_id', 'timestamp'], + false, + ); + } +} diff --git a/lib/Migration/Version2006Date20170808154933.php b/lib/Migration/Version2006Date20170808154933.php index 7f91122cc..ed98e142a 100644 --- a/lib/Migration/Version2006Date20170808154933.php +++ b/lib/Migration/Version2006Date20170808154933.php @@ -95,6 +95,7 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op // FIXME Fixed install, see Version2006Date20170808155040: $table->addIndex(['affecteduser', 'app', 'timestamp'], 'activity_filter_app'); $table->addIndex(['affecteduser', 'type', 'app', 'timestamp'], 'activity_filter'); $table->addIndex(['object_type', 'object_id'], 'activity_object'); + $table->addIndex(['affecteduser', 'object_type', 'object_id', 'timestamp'], 'activity_object_user'); } if (!$schema->hasTable('activity_mq')) {