diff options
author | Chocobozzz <me@florianbigard.com> | 2019-08-01 10:15:28 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-08-01 10:15:28 +0200 |
commit | 970ceac0a6bf4990b8924738591df4949491ec9b (patch) | |
tree | 444070d8409fced91971c4401e65640d6fd13cbf /server/models/video | |
parent | bfbd912886eba17b4aa9a40dcef2fddc685d85bf (diff) | |
download | PeerTube-970ceac0a6bf4990b8924738591df4949491ec9b.tar.gz PeerTube-970ceac0a6bf4990b8924738591df4949491ec9b.tar.zst PeerTube-970ceac0a6bf4990b8924738591df4949491ec9b.zip |
Fix multiple server tests
Diffstat (limited to 'server/models/video')
-rw-r--r-- | server/models/video/video-comment.ts | 19 | ||||
-rw-r--r-- | server/models/video/video-share.ts | 29 |
2 files changed, 38 insertions, 10 deletions
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts index 536b6cb3e..28e5818cd 100644 --- a/server/models/video/video-comment.ts +++ b/server/models/video/video-comment.ts | |||
@@ -472,7 +472,24 @@ export class VideoCommentModel extends Model<VideoCommentModel> { | |||
472 | [Op.lt]: beforeUpdatedAt | 472 | [Op.lt]: beforeUpdatedAt |
473 | }, | 473 | }, |
474 | videoId | 474 | videoId |
475 | } | 475 | }, |
476 | include: [ | ||
477 | { | ||
478 | required: true, | ||
479 | model: AccountModel.unscoped(), | ||
480 | include: [ | ||
481 | { | ||
482 | required: true, | ||
483 | model: ActorModel.unscoped(), | ||
484 | where: { | ||
485 | serverId: { | ||
486 | [Op.ne]: null | ||
487 | } | ||
488 | } | ||
489 | } | ||
490 | ] | ||
491 | } | ||
492 | ] | ||
476 | } | 493 | } |
477 | 494 | ||
478 | return VideoCommentModel.destroy(query) | 495 | return VideoCommentModel.destroy(query) |
diff --git a/server/models/video/video-share.ts b/server/models/video/video-share.ts index fda2d7cea..3bab3c027 100644 --- a/server/models/video/video-share.ts +++ b/server/models/video/video-share.ts | |||
@@ -1,4 +1,3 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import * as Bluebird from 'bluebird' | 1 | import * as Bluebird from 'bluebird' |
3 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' | 2 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' |
4 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 3 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
@@ -8,6 +7,7 @@ import { ActorModel } from '../activitypub/actor' | |||
8 | import { throwIfNotValid } from '../utils' | 7 | import { throwIfNotValid } from '../utils' |
9 | import { VideoModel } from './video' | 8 | import { VideoModel } from './video' |
10 | import { VideoChannelModel } from './video-channel' | 9 | import { VideoChannelModel } from './video-channel' |
10 | import { Op, Transaction } from 'sequelize' | ||
11 | 11 | ||
12 | enum ScopeNames { | 12 | enum ScopeNames { |
13 | FULL = 'FULL', | 13 | FULL = 'FULL', |
@@ -88,7 +88,7 @@ export class VideoShareModel extends Model<VideoShareModel> { | |||
88 | }) | 88 | }) |
89 | Video: VideoModel | 89 | Video: VideoModel |
90 | 90 | ||
91 | static load (actorId: number, videoId: number, t?: Sequelize.Transaction) { | 91 | static load (actorId: number, videoId: number, t?: Transaction) { |
92 | return VideoShareModel.scope(ScopeNames.WITH_ACTOR).findOne({ | 92 | return VideoShareModel.scope(ScopeNames.WITH_ACTOR).findOne({ |
93 | where: { | 93 | where: { |
94 | actorId, | 94 | actorId, |
@@ -98,7 +98,7 @@ export class VideoShareModel extends Model<VideoShareModel> { | |||
98 | }) | 98 | }) |
99 | } | 99 | } |
100 | 100 | ||
101 | static loadByUrl (url: string, t: Sequelize.Transaction) { | 101 | static loadByUrl (url: string, t: Transaction) { |
102 | return VideoShareModel.scope(ScopeNames.FULL).findOne({ | 102 | return VideoShareModel.scope(ScopeNames.FULL).findOne({ |
103 | where: { | 103 | where: { |
104 | url | 104 | url |
@@ -107,7 +107,7 @@ export class VideoShareModel extends Model<VideoShareModel> { | |||
107 | }) | 107 | }) |
108 | } | 108 | } |
109 | 109 | ||
110 | static loadActorsByShare (videoId: number, t: Sequelize.Transaction) { | 110 | static loadActorsByShare (videoId: number, t: Transaction) { |
111 | const query = { | 111 | const query = { |
112 | where: { | 112 | where: { |
113 | videoId | 113 | videoId |
@@ -125,7 +125,7 @@ export class VideoShareModel extends Model<VideoShareModel> { | |||
125 | .then(res => res.map(r => r.Actor)) | 125 | .then(res => res.map(r => r.Actor)) |
126 | } | 126 | } |
127 | 127 | ||
128 | static loadActorsWhoSharedVideosOf (actorOwnerId: number, t: Sequelize.Transaction): Bluebird<ActorModel[]> { | 128 | static loadActorsWhoSharedVideosOf (actorOwnerId: number, t: Transaction): Bluebird<ActorModel[]> { |
129 | const query = { | 129 | const query = { |
130 | attributes: [], | 130 | attributes: [], |
131 | include: [ | 131 | include: [ |
@@ -163,7 +163,7 @@ export class VideoShareModel extends Model<VideoShareModel> { | |||
163 | .then(res => res.map(r => r.Actor)) | 163 | .then(res => res.map(r => r.Actor)) |
164 | } | 164 | } |
165 | 165 | ||
166 | static loadActorsByVideoChannel (videoChannelId: number, t: Sequelize.Transaction): Bluebird<ActorModel[]> { | 166 | static loadActorsByVideoChannel (videoChannelId: number, t: Transaction): Bluebird<ActorModel[]> { |
167 | const query = { | 167 | const query = { |
168 | attributes: [], | 168 | attributes: [], |
169 | include: [ | 169 | include: [ |
@@ -188,7 +188,7 @@ export class VideoShareModel extends Model<VideoShareModel> { | |||
188 | .then(res => res.map(r => r.Actor)) | 188 | .then(res => res.map(r => r.Actor)) |
189 | } | 189 | } |
190 | 190 | ||
191 | static listAndCountByVideoId (videoId: number, start: number, count: number, t?: Sequelize.Transaction) { | 191 | static listAndCountByVideoId (videoId: number, start: number, count: number, t?: Transaction) { |
192 | const query = { | 192 | const query = { |
193 | offset: start, | 193 | offset: start, |
194 | limit: count, | 194 | limit: count, |
@@ -205,10 +205,21 @@ export class VideoShareModel extends Model<VideoShareModel> { | |||
205 | const query = { | 205 | const query = { |
206 | where: { | 206 | where: { |
207 | updatedAt: { | 207 | updatedAt: { |
208 | [Sequelize.Op.lt]: beforeUpdatedAt | 208 | [Op.lt]: beforeUpdatedAt |
209 | }, | 209 | }, |
210 | videoId | 210 | videoId |
211 | } | 211 | }, |
212 | include: [ | ||
213 | { | ||
214 | model: ActorModel.unscoped(), | ||
215 | required: true, | ||
216 | where: { | ||
217 | serverId: { | ||
218 | [ Op.ne ]: null | ||
219 | } | ||
220 | } | ||
221 | } | ||
222 | ] | ||
212 | } | 223 | } |
213 | 224 | ||
214 | return VideoShareModel.destroy(query) | 225 | return VideoShareModel.destroy(query) |