aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video')
-rw-r--r--server/models/video/video-interface.ts1
-rw-r--r--server/models/video/video.ts47
2 files changed, 19 insertions, 29 deletions
diff --git a/server/models/video/video-interface.ts b/server/models/video/video-interface.ts
index be140de86..2a63350af 100644
--- a/server/models/video/video-interface.ts
+++ b/server/models/video/video-interface.ts
@@ -50,7 +50,6 @@ export namespace VideoMethods {
50 export type ListUserVideosForApi = (userId: number, start: number, count: number, sort: string) => Bluebird< ResultList<VideoInstance> > 50 export type ListUserVideosForApi = (userId: number, start: number, count: number, sort: string) => Bluebird< ResultList<VideoInstance> >
51 export type SearchAndPopulateAccountAndServerAndTags = ( 51 export type SearchAndPopulateAccountAndServerAndTags = (
52 value: string, 52 value: string,
53 field: string,
54 start: number, 53 start: number,
55 count: number, 54 count: number,
56 sort: string 55 sort: string
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index f3469c1de..4dce8e2fc 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1070,7 +1070,7 @@ loadByUUIDAndPopulateAccountAndServerAndTags = function (uuid: string) {
1070 return Video.findOne(options) 1070 return Video.findOne(options)
1071} 1071}
1072 1072
1073searchAndPopulateAccountAndServerAndTags = function (value: string, field: string, start: number, count: number, sort: string) { 1073searchAndPopulateAccountAndServerAndTags = function (value: string, start: number, count: number, sort: string) {
1074 const serverInclude: Sequelize.IncludeOptions = { 1074 const serverInclude: Sequelize.IncludeOptions = {
1075 model: Video['sequelize'].models.Server, 1075 model: Video['sequelize'].models.Server,
1076 required: false 1076 required: false
@@ -1099,33 +1099,24 @@ searchAndPopulateAccountAndServerAndTags = function (value: string, field: strin
1099 order: [ getSort(sort), [ Video['sequelize'].models.Tag, 'name', 'ASC' ] ] 1099 order: [ getSort(sort), [ Video['sequelize'].models.Tag, 'name', 'ASC' ] ]
1100 } 1100 }
1101 1101
1102 if (field === 'tags') { 1102 // TODO: search on tags too
1103 const escapedValue = Video['sequelize'].escape('%' + value + '%') 1103 // const escapedValue = Video['sequelize'].escape('%' + value + '%')
1104 query.where['id'][Sequelize.Op.in] = Video['sequelize'].literal( 1104 // query.where['id'][Sequelize.Op.in] = Video['sequelize'].literal(
1105 `(SELECT "VideoTags"."videoId" 1105 // `(SELECT "VideoTags"."videoId"
1106 FROM "Tags" 1106 // FROM "Tags"
1107 INNER JOIN "VideoTags" ON "Tags"."id" = "VideoTags"."tagId" 1107 // INNER JOIN "VideoTags" ON "Tags"."id" = "VideoTags"."tagId"
1108 WHERE name ILIKE ${escapedValue} 1108 // WHERE name ILIKE ${escapedValue}
1109 )` 1109 // )`
1110 ) 1110 // )
1111 } else if (field === 'host') { 1111
1112 // FIXME: Include our server? (not stored in the database) 1112 // TODO: search on account too
1113 serverInclude.where = { 1113 // accountInclude.where = {
1114 host: { 1114 // name: {
1115 [Sequelize.Op.iLike]: '%' + value + '%' 1115 // [Sequelize.Op.iLike]: '%' + value + '%'
1116 } 1116 // }
1117 } 1117 // }
1118 serverInclude.required = true 1118 query.where['name'] = {
1119 } else if (field === 'account') { 1119 [Sequelize.Op.iLike]: '%' + value + '%'
1120 accountInclude.where = {
1121 name: {
1122 [Sequelize.Op.iLike]: '%' + value + '%'
1123 }
1124 }
1125 } else {
1126 query.where[field] = {
1127 [Sequelize.Op.iLike]: '%' + value + '%'
1128 }
1129 } 1120 }
1130 1121
1131 query.include = [ 1122 query.include = [