aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account/account-video-rate.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-18 11:28:17 +0200
committerChocobozzz <me@florianbigard.com>2019-04-24 16:26:20 +0200
commit1735c825726edaa0af5035cb6cbb0cc0db502c6d (patch)
tree7bbb442f2cb4d7be58a4e08d87f5974403a3047c /server/models/account/account-video-rate.ts
parente8bafea35bc930cb8ac5b2d521a188642a1adffe (diff)
downloadPeerTube-1735c825726edaa0af5035cb6cbb0cc0db502c6d.tar.gz
PeerTube-1735c825726edaa0af5035cb6cbb0cc0db502c6d.tar.zst
PeerTube-1735c825726edaa0af5035cb6cbb0cc0db502c6d.zip
Update sequelize
Diffstat (limited to 'server/models/account/account-video-rate.ts')
-rw-r--r--server/models/account/account-video-rate.ts17
1 files changed, 8 insertions, 9 deletions
diff --git a/server/models/account/account-video-rate.ts b/server/models/account/account-video-rate.ts
index 78a897a65..59f586b54 100644
--- a/server/models/account/account-video-rate.ts
+++ b/server/models/account/account-video-rate.ts
@@ -1,16 +1,15 @@
1import { values } from 'lodash' 1import { values } from 'lodash'
2import { Transaction, Op } from 'sequelize' 2import { FindOptions, Op, Transaction } from 'sequelize'
3import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' 3import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
4import { IFindOptions } from 'sequelize-typescript/lib/interfaces/IFindOptions'
5import { VideoRateType } from '../../../shared/models/videos' 4import { VideoRateType } from '../../../shared/models/videos'
6import { CONSTRAINTS_FIELDS, VIDEO_RATE_TYPES } from '../../initializers/constants' 5import { CONSTRAINTS_FIELDS, VIDEO_RATE_TYPES } from '../../initializers/constants'
7import { VideoModel } from '../video/video' 6import { VideoModel } from '../video/video'
8import { AccountModel } from './account' 7import { AccountModel } from './account'
9import { ActorModel } from '../activitypub/actor' 8import { ActorModel } from '../activitypub/actor'
10import { throwIfNotValid, getSort } from '../utils' 9import { getSort, throwIfNotValid } from '../utils'
11import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' 10import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
12import { AccountVideoRate } from '../../../shared' 11import { AccountVideoRate } from '../../../shared'
13import { VideoChannelModel, ScopeNames as VideoChannelScopeNames } from '../video/video-channel' 12import { ScopeNames as VideoChannelScopeNames, VideoChannelModel } from '../video/video-channel'
14 13
15/* 14/*
16 Account rates per video. 15 Account rates per video.
@@ -40,7 +39,7 @@ import { VideoChannelModel, ScopeNames as VideoChannelScopeNames } from '../vide
40export class AccountVideoRateModel extends Model<AccountVideoRateModel> { 39export class AccountVideoRateModel extends Model<AccountVideoRateModel> {
41 40
42 @AllowNull(false) 41 @AllowNull(false)
43 @Column(DataType.ENUM(values(VIDEO_RATE_TYPES))) 42 @Column(DataType.ENUM(...values(VIDEO_RATE_TYPES)))
44 type: VideoRateType 43 type: VideoRateType
45 44
46 @AllowNull(false) 45 @AllowNull(false)
@@ -79,7 +78,7 @@ export class AccountVideoRateModel extends Model<AccountVideoRateModel> {
79 Account: AccountModel 78 Account: AccountModel
80 79
81 static load (accountId: number, videoId: number, transaction?: Transaction) { 80 static load (accountId: number, videoId: number, transaction?: Transaction) {
82 const options: IFindOptions<AccountVideoRateModel> = { 81 const options: FindOptions = {
83 where: { 82 where: {
84 accountId, 83 accountId,
85 videoId 84 videoId
@@ -97,7 +96,7 @@ export class AccountVideoRateModel extends Model<AccountVideoRateModel> {
97 type?: string, 96 type?: string,
98 accountId: number 97 accountId: number
99 }) { 98 }) {
100 const query: IFindOptions<AccountVideoRateModel> = { 99 const query: FindOptions = {
101 offset: options.start, 100 offset: options.start,
102 limit: options.count, 101 limit: options.count,
103 order: getSort(options.sort), 102 order: getSort(options.sort),
@@ -123,7 +122,7 @@ export class AccountVideoRateModel extends Model<AccountVideoRateModel> {
123 } 122 }
124 123
125 static loadLocalAndPopulateVideo (rateType: VideoRateType, accountName: string, videoId: number, transaction?: Transaction) { 124 static loadLocalAndPopulateVideo (rateType: VideoRateType, accountName: string, videoId: number, transaction?: Transaction) {
126 const options: IFindOptions<AccountVideoRateModel> = { 125 const options: FindOptions = {
127 where: { 126 where: {
128 videoId, 127 videoId,
129 type: rateType 128 type: rateType
@@ -155,7 +154,7 @@ export class AccountVideoRateModel extends Model<AccountVideoRateModel> {
155 } 154 }
156 155
157 static loadByUrl (url: string, transaction: Transaction) { 156 static loadByUrl (url: string, transaction: Transaction) {
158 const options: IFindOptions<AccountVideoRateModel> = { 157 const options: FindOptions = {
159 where: { 158 where: {
160 url 159 url
161 } 160 }