diff options
author | PhieF <phoenamandre@gmail.com> | 2018-06-27 14:24:49 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-06-27 14:24:49 +0200 |
commit | 61b909b9bf849516f30dab2bf5977acfbbddc5c6 (patch) | |
tree | 8724ecfe2d8f054dde21f9e2acb32902321dfcf5 /server/models | |
parent | adc236fee3c40bf1fbaa4ad4fc22a7ecb65fb09f (diff) | |
download | PeerTube-61b909b9bf849516f30dab2bf5977acfbbddc5c6.tar.gz PeerTube-61b909b9bf849516f30dab2bf5977acfbbddc5c6.tar.zst PeerTube-61b909b9bf849516f30dab2bf5977acfbbddc5c6.zip |
Filter by category (#720)
* get videos with specific category (api)
* update api doc with category
* add url parameter to filter by category
* fix lint issues
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/video/video.ts | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 0041e4d38..0af70cadf 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -106,6 +106,7 @@ export enum ScopeNames { | |||
106 | actorId: number, | 106 | actorId: number, |
107 | hideNSFW: boolean, | 107 | hideNSFW: boolean, |
108 | filter?: VideoFilter, | 108 | filter?: VideoFilter, |
109 | category?: number, | ||
109 | withFiles?: boolean, | 110 | withFiles?: boolean, |
110 | accountId?: number, | 111 | accountId?: number, |
111 | videoChannelId?: number | 112 | videoChannelId?: number |
@@ -215,6 +216,10 @@ export enum ScopeNames { | |||
215 | query.where['nsfw'] = false | 216 | query.where['nsfw'] = false |
216 | } | 217 | } |
217 | 218 | ||
219 | if (options.category) { | ||
220 | query.where['category'] = options.category | ||
221 | } | ||
222 | |||
218 | if (options.accountId) { | 223 | if (options.accountId) { |
219 | accountInclude.where = { | 224 | accountInclude.where = { |
220 | id: options.accountId | 225 | id: options.accountId |
@@ -730,6 +735,7 @@ export class VideoModel extends Model<VideoModel> { | |||
730 | sort: string, | 735 | sort: string, |
731 | hideNSFW: boolean, | 736 | hideNSFW: boolean, |
732 | withFiles: boolean, | 737 | withFiles: boolean, |
738 | category?: number, | ||
733 | filter?: VideoFilter, | 739 | filter?: VideoFilter, |
734 | accountId?: number, | 740 | accountId?: number, |
735 | videoChannelId?: number | 741 | videoChannelId?: number |
@@ -746,6 +752,7 @@ export class VideoModel extends Model<VideoModel> { | |||
746 | ScopeNames.AVAILABLE_FOR_LIST, { | 752 | ScopeNames.AVAILABLE_FOR_LIST, { |
747 | actorId: serverActor.id, | 753 | actorId: serverActor.id, |
748 | hideNSFW: options.hideNSFW, | 754 | hideNSFW: options.hideNSFW, |
755 | category: options.category, | ||
749 | filter: options.filter, | 756 | filter: options.filter, |
750 | withFiles: options.withFiles, | 757 | withFiles: options.withFiles, |
751 | accountId: options.accountId, | 758 | accountId: options.accountId, |