X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Faccount%2Fuser-video-history.ts;h=522eebeaf92206ca897c6b106aa138177ea6cc74;hb=3487330d308166afb542cbacae0475693c0b059e;hp=49d2def8158386a64aa17c2b1b07cbdce2f78253;hpb=8f0bc73d7d5f4c88cbc5588a0ece12b3855c8f98;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/account/user-video-history.ts b/server/models/account/user-video-history.ts index 49d2def81..522eebeaf 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/typings/models' @Table({ tableName: 'userVideoHistory', @@ -54,11 +55,11 @@ export class UserVideoHistoryModel extends Model { }) User: UserModel - static listForApi (user: UserModel, start: number, count: number) { + static listForApi (user: MUserAccountId, start: number, count: number) { return VideoModel.listForApi({ start, count, - sort: '-UserVideoHistories.updatedAt', + sort: '-"userVideoHistory"."updatedAt"', nsfw: null, // All includeLocalVideos: true, withFiles: false, @@ -67,7 +68,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 @@ -76,7 +77,7 @@ export class UserVideoHistoryModel extends Model { } if (beforeDate) { - query.where.updatedAt = { + query.where['updatedAt'] = { [Op.lt]: beforeDate } }