- return VideoPlaylistModel
- .scope(scopes)
- .findAndCountAll(query)
- .then(({ rows, count }) => {
- return { total: count, data: rows }
- })
+ const scopesCount: (string | ScopeOptions)[] = [
+ {
+ method: [
+ ScopeNames.AVAILABLE_FOR_LIST,
+
+ {
+ ...commonAvailableForListOptions,
+
+ withVideos: options.withVideos || false,
+ forCount: true
+ } as AvailableForListOptions
+ ]
+ },
+ ScopeNames.WITH_VIDEOS_LENGTH
+ ]
+
+ return Promise.all([
+ VideoPlaylistModel.scope(scopesCount).count(),
+ VideoPlaylistModel.scope(scopesFind).findAll(query)
+ ]).then(([ count, rows ]) => ({ total: count, data: rows }))
+ }
+
+ static searchForApi (options: Pick<AvailableForListOptions, 'followerActorId' | 'search' | 'host' | 'uuids'> & {
+ start: number
+ count: number
+ sort: string
+ }) {
+ return VideoPlaylistModel.listForApi({
+ ...options,
+
+ type: VideoPlaylistType.REGULAR,
+ listMyPlaylists: false,
+ withVideos: true
+ })