From 822c7e610d19e3320519a6ae5c90c01db971f03f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 27 Dec 2019 09:04:04 +0100 Subject: Fix playlist search --- server/models/video/video-playlist.ts | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'server/models/video/video-playlist.ts') diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts index ef87a7ee9..71a580249 100644 --- a/server/models/video/video-playlist.ts +++ b/server/models/video/video-playlist.ts @@ -13,11 +13,10 @@ import { Model, Scopes, Table, - UpdatedAt, - Sequelize + UpdatedAt } from 'sequelize-typescript' import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' -import { buildServerIdsFollowedBy, buildWhereIdOrUUID, getSort, isOutdated, throwIfNotValid, createSimilarityAttribute } from '../utils' +import { buildServerIdsFollowedBy, buildWhereIdOrUUID, getSort, isOutdated, throwIfNotValid } from '../utils' import { isVideoPlaylistDescriptionValid, isVideoPlaylistNameValid, @@ -46,7 +45,8 @@ import { ActivityIconObject } from '../../../shared/models/activitypub/objects' import { FindOptions, literal, Op, ScopeOptions, Transaction, WhereOptions } from 'sequelize' import * as Bluebird from 'bluebird' import { - MVideoPlaylistAccountThumbnail, MVideoPlaylistAP, + MVideoPlaylistAccountThumbnail, + MVideoPlaylistAP, MVideoPlaylistFormattable, MVideoPlaylistFull, MVideoPlaylistFullSummary, @@ -166,18 +166,9 @@ type AvailableForListOptions = { } if (options.search) { - const escapedSearch = VideoPlaylistModel.sequelize.escape(options.search) - const escapedLikeSearch = VideoPlaylistModel.sequelize.escape('%' + options.search + '%') whereAnd.push({ - id: { - [ Op.in ]: Sequelize.literal( - '(' + - 'SELECT "videoPlaylist"."id" FROM "videoPlaylist" ' + - 'WHERE ' + - 'lower(immutable_unaccent("videoPlaylist"."name")) % lower(immutable_unaccent(' + escapedSearch + ')) OR ' + - 'lower(immutable_unaccent("videoPlaylist"."name")) LIKE lower(immutable_unaccent(' + escapedLikeSearch + '))' + - ')' - ) + name: { + [ Op.iLike ]: '%' + options.search + '%' } }) } -- cgit v1.2.3