X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Faccount%2Fuser-video-history.ts;h=6be1d65ea19e76d2e29d0f0b86960f102a02dea3;hb=4024c44f9027a32809931de0692d40d001df721c;hp=a862fc45fb859b0d842877c888b76233aec0962a;hpb=97567dd81f508dd6295ac4d73d849aa2ce0a6549;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/account/user-video-history.ts b/server/models/account/user-video-history.ts index a862fc45f..6be1d65ea 100644 --- a/server/models/account/user-video-history.ts +++ b/server/models/account/user-video-history.ts @@ -1,7 +1,8 @@ import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, IsInt, Model, Table, UpdatedAt } from 'sequelize-typescript' import { VideoModel } from '../video/video' import { UserModel } from './user' -import { Transaction, Op, DestroyOptions } from 'sequelize' +import { DestroyOptions, Op, Transaction } from 'sequelize' +import { MUserAccountId, MUserId } from '@server/types/models' @Table({ tableName: 'userVideoHistory', @@ -18,7 +19,7 @@ import { Transaction, Op, DestroyOptions } from 'sequelize' } ] }) -export class UserVideoHistoryModel extends Model { +export class UserVideoHistoryModel extends Model { @CreatedAt createdAt: Date @@ -54,11 +55,12 @@ export class UserVideoHistoryModel extends Model { }) User: UserModel - static listForApi (user: UserModel, start: number, count: number) { + static listForApi (user: MUserAccountId, start: number, count: number, search?: string) { return VideoModel.listForApi({ start, count, - sort: '-UserVideoHistories.updatedAt', + search, + sort: '-"userVideoHistory"."updatedAt"', nsfw: null, // All includeLocalVideos: true, withFiles: false, @@ -67,7 +69,7 @@ export class UserVideoHistoryModel extends Model { }) } - static removeUserHistoryBefore (user: UserModel, beforeDate: string, t: Transaction) { + static removeUserHistoryBefore (user: MUserId, beforeDate: string, t: Transaction) { const query: DestroyOptions = { where: { userId: user.id