mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-12-02 05:19:17 -06:00
Optimize channel search query
This commit is contained in:
parent
9ee92651f6
commit
c3c2ab1c8b
@ -69,9 +69,9 @@ type AvailableForListOptions = {
|
||||
|
||||
// Only list local channels OR channels that are on an instance followed by actorId
|
||||
const inQueryInstanceFollow = '(' +
|
||||
'SELECT "actor"."serverId" FROM "actor" ' +
|
||||
'INNER JOIN "actorFollow" ON "actorFollow"."targetActorId" = actor.id ' +
|
||||
'WHERE "actorFollow"."actorId" = ' + actorIdNumber +
|
||||
'SELECT "actor"."serverId" FROM "actorFollow" ' +
|
||||
'INNER JOIN "actor" ON actor.id= "actorFollow"."targetActorId" ' +
|
||||
'WHERE "actor"."id" = ' + actorIdNumber +
|
||||
')'
|
||||
|
||||
return {
|
||||
@ -253,15 +253,14 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
|
||||
limit: options.count,
|
||||
order: getSort(options.sort),
|
||||
where: {
|
||||
id: {
|
||||
[ Sequelize.Op.in ]: Sequelize.literal(
|
||||
'(' +
|
||||
'SELECT id FROM "videoChannel" WHERE ' +
|
||||
'lower(immutable_unaccent("name")) % lower(immutable_unaccent(' + escapedSearch + ')) OR ' +
|
||||
'lower(immutable_unaccent("name")) LIKE lower(immutable_unaccent(' + escapedLikeSearch + '))' +
|
||||
')'
|
||||
[Sequelize.Op.or]: [
|
||||
Sequelize.literal(
|
||||
'lower(immutable_unaccent("VideoChannelModel"."name")) % lower(immutable_unaccent(' + escapedSearch + '))'
|
||||
),
|
||||
Sequelize.literal(
|
||||
'lower(immutable_unaccent("VideoChannelModel"."name")) LIKE lower(immutable_unaccent(' + escapedLikeSearch + '))'
|
||||
)
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user