Optimize channel search query
This commit is contained in:
parent
9ee92651f6
commit
c3c2ab1c8b
1 changed files with 10 additions and 11 deletions
|
@ -69,9 +69,9 @@ type AvailableForListOptions = {
|
||||||
|
|
||||||
// Only list local channels OR channels that are on an instance followed by actorId
|
// Only list local channels OR channels that are on an instance followed by actorId
|
||||||
const inQueryInstanceFollow = '(' +
|
const inQueryInstanceFollow = '(' +
|
||||||
'SELECT "actor"."serverId" FROM "actor" ' +
|
'SELECT "actor"."serverId" FROM "actorFollow" ' +
|
||||||
'INNER JOIN "actorFollow" ON "actorFollow"."targetActorId" = actor.id ' +
|
'INNER JOIN "actor" ON actor.id= "actorFollow"."targetActorId" ' +
|
||||||
'WHERE "actorFollow"."actorId" = ' + actorIdNumber +
|
'WHERE "actor"."id" = ' + actorIdNumber +
|
||||||
')'
|
')'
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -253,15 +253,14 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
|
||||||
limit: options.count,
|
limit: options.count,
|
||||||
order: getSort(options.sort),
|
order: getSort(options.sort),
|
||||||
where: {
|
where: {
|
||||||
id: {
|
[Sequelize.Op.or]: [
|
||||||
[ Sequelize.Op.in ]: Sequelize.literal(
|
Sequelize.literal(
|
||||||
'(' +
|
'lower(immutable_unaccent("VideoChannelModel"."name")) % lower(immutable_unaccent(' + escapedSearch + '))'
|
||||||
'SELECT id FROM "videoChannel" WHERE ' +
|
),
|
||||||
'lower(immutable_unaccent("name")) % lower(immutable_unaccent(' + escapedSearch + ')) OR ' +
|
Sequelize.literal(
|
||||||
'lower(immutable_unaccent("name")) LIKE lower(immutable_unaccent(' + escapedLikeSearch + '))' +
|
'lower(immutable_unaccent("VideoChannelModel"."name")) LIKE lower(immutable_unaccent(' + escapedLikeSearch + '))'
|
||||||
')'
|
|
||||||
)
|
)
|
||||||
}
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue