aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-channel.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-28 15:16:04 +0200
committerChocobozzz <me@florianbigard.com>2018-08-28 15:16:04 +0200
commitc3c2ab1c8b52945df567c59118a7c77fdd6a1d4d (patch)
treee210ae8226539ad3e2d776eec19ad44eed0d347e /server/models/video/video-channel.ts
parent9ee92651f64bf576c57eafe81fb3ab82def0d9e8 (diff)
downloadPeerTube-c3c2ab1c8b52945df567c59118a7c77fdd6a1d4d.tar.gz
PeerTube-c3c2ab1c8b52945df567c59118a7c77fdd6a1d4d.tar.zst
PeerTube-c3c2ab1c8b52945df567c59118a7c77fdd6a1d4d.zip
Optimize channel search query
Diffstat (limited to 'server/models/video/video-channel.ts')
-rw-r--r--server/models/video/video-channel.ts21
1 files changed, 10 insertions, 11 deletions
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts
index 7d717fc68..e70e52515 100644
--- a/server/models/video/video-channel.ts
+++ b/server/models/video/video-channel.ts
@@ -69,9 +69,9 @@ type AvailableForListOptions = {
69 69
70 // Only list local channels OR channels that are on an instance followed by actorId 70 // Only list local channels OR channels that are on an instance followed by actorId
71 const inQueryInstanceFollow = '(' + 71 const inQueryInstanceFollow = '(' +
72 'SELECT "actor"."serverId" FROM "actor" ' + 72 'SELECT "actor"."serverId" FROM "actorFollow" ' +
73 'INNER JOIN "actorFollow" ON "actorFollow"."targetActorId" = actor.id ' + 73 'INNER JOIN "actor" ON actor.id= "actorFollow"."targetActorId" ' +
74 'WHERE "actorFollow"."actorId" = ' + actorIdNumber + 74 'WHERE "actor"."id" = ' + actorIdNumber +
75 ')' 75 ')'
76 76
77 return { 77 return {
@@ -253,15 +253,14 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
253 limit: options.count, 253 limit: options.count,
254 order: getSort(options.sort), 254 order: getSort(options.sort),
255 where: { 255 where: {
256 id: { 256 [Sequelize.Op.or]: [
257 [ Sequelize.Op.in ]: Sequelize.literal( 257 Sequelize.literal(
258 '(' + 258 'lower(immutable_unaccent("VideoChannelModel"."name")) % lower(immutable_unaccent(' + escapedSearch + '))'
259 'SELECT id FROM "videoChannel" WHERE ' + 259 ),
260 'lower(immutable_unaccent("name")) % lower(immutable_unaccent(' + escapedSearch + ')) OR ' + 260 Sequelize.literal(
261 'lower(immutable_unaccent("name")) LIKE lower(immutable_unaccent(' + escapedLikeSearch + '))' + 261 'lower(immutable_unaccent("VideoChannelModel"."name")) LIKE lower(immutable_unaccent(' + escapedLikeSearch + '))'
262 ')'
263 ) 262 )
264 } 263 ]
265 } 264 }
266 } 265 }
267 266