diff options
author | Chocobozzz <me@florianbigard.com> | 2019-02-21 14:28:06 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-02-21 14:40:10 +0100 |
commit | 9b39106d5757caf221a88e42e05167a6fac479c6 (patch) | |
tree | ce3ac7907135d82ad13abf648eff4f963448227e | |
parent | 374c1db98cf22527f5b362c70d3c50e3be4c8885 (diff) | |
download | PeerTube-9b39106d5757caf221a88e42e05167a6fac479c6.tar.gz PeerTube-9b39106d5757caf221a88e42e05167a6fac479c6.tar.zst PeerTube-9b39106d5757caf221a88e42e05167a6fac479c6.zip |
findById -> findByPk
-rw-r--r-- | package.json | 4 | ||||
-rw-r--r-- | server/initializers/migrations/0080-video-channels.ts | 2 | ||||
-rw-r--r-- | server/models/account/account.ts | 3 | ||||
-rw-r--r-- | server/models/account/user.ts | 2 | ||||
-rw-r--r-- | server/models/activitypub/actor.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-change-ownership.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-channel.ts | 6 | ||||
-rw-r--r-- | server/models/video/video-file.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-import.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-streaming-playlist.ts | 2 | ||||
-rw-r--r-- | server/models/video/video.ts | 2 | ||||
-rw-r--r-- | server/tests/api/check-params/user-subscriptions.ts | 2 | ||||
-rw-r--r-- | server/tests/api/server/email.ts | 3 | ||||
-rw-r--r-- | server/tests/api/server/follows.ts | 2 | ||||
-rw-r--r-- | yarn.lock | 16 |
15 files changed, 26 insertions, 26 deletions
diff --git a/package.json b/package.json index a4a545b54..fffbc8e32 100644 --- a/package.json +++ b/package.json | |||
@@ -142,8 +142,8 @@ | |||
142 | "reflect-metadata": "^0.1.12", | 142 | "reflect-metadata": "^0.1.12", |
143 | "request": "^2.81.0", | 143 | "request": "^2.81.0", |
144 | "scripty": "^1.5.0", | 144 | "scripty": "^1.5.0", |
145 | "sequelize": "4.41.2", | 145 | "sequelize": "4.42.0", |
146 | "sequelize-typescript": "0.6.6", | 146 | "sequelize-typescript": "0.6.7", |
147 | "sharp": "^0.21.0", | 147 | "sharp": "^0.21.0", |
148 | "sitemap": "^2.1.0", | 148 | "sitemap": "^2.1.0", |
149 | "socket.io": "^2.2.0", | 149 | "socket.io": "^2.2.0", |
diff --git a/server/initializers/migrations/0080-video-channels.ts b/server/initializers/migrations/0080-video-channels.ts index f19721517..0e17a4ccd 100644 --- a/server/initializers/migrations/0080-video-channels.ts +++ b/server/initializers/migrations/0080-video-channels.ts | |||
@@ -74,7 +74,7 @@ async function up (utils: { | |||
74 | for (const rawVideo of rawVideos) { | 74 | for (const rawVideo of rawVideos) { |
75 | const videoChannel = await utils.db.VideoChannel.findOne({ where: { authorId: rawVideo.authorId } }) | 75 | const videoChannel = await utils.db.VideoChannel.findOne({ where: { authorId: rawVideo.authorId } }) |
76 | 76 | ||
77 | const video = await utils.db.Video.findById(rawVideo.id) | 77 | const video = await utils.db.Video.findByPk(rawVideo.id) |
78 | video.channelId = videoChannel.id | 78 | video.channelId = videoChannel.id |
79 | await video.save() | 79 | await video.save() |
80 | } | 80 | } |
diff --git a/server/models/account/account.ts b/server/models/account/account.ts index 747b51afb..ee22d8528 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts | |||
@@ -24,7 +24,6 @@ import { getSort, throwIfNotValid } from '../utils' | |||
24 | import { VideoChannelModel } from '../video/video-channel' | 24 | import { VideoChannelModel } from '../video/video-channel' |
25 | import { VideoCommentModel } from '../video/video-comment' | 25 | import { VideoCommentModel } from '../video/video-comment' |
26 | import { UserModel } from './user' | 26 | import { UserModel } from './user' |
27 | import * as Bluebird from '../../helpers/custom-validators/accounts' | ||
28 | import { CONFIG } from '../../initializers' | 27 | import { CONFIG } from '../../initializers' |
29 | 28 | ||
30 | @DefaultScope({ | 29 | @DefaultScope({ |
@@ -136,7 +135,7 @@ export class AccountModel extends Model<AccountModel> { | |||
136 | } | 135 | } |
137 | 136 | ||
138 | static load (id: number, transaction?: Sequelize.Transaction) { | 137 | static load (id: number, transaction?: Sequelize.Transaction) { |
139 | return AccountModel.findById(id, { transaction }) | 138 | return AccountModel.findByPk(id, { transaction }) |
140 | } | 139 | } |
141 | 140 | ||
142 | static loadByUUID (uuid: string) { | 141 | static loadByUUID (uuid: string) { |
diff --git a/server/models/account/user.ts b/server/models/account/user.ts index 017a96657..8aff9f497 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts | |||
@@ -341,7 +341,7 @@ export class UserModel extends Model<UserModel> { | |||
341 | } | 341 | } |
342 | 342 | ||
343 | static loadById (id: number) { | 343 | static loadById (id: number) { |
344 | return UserModel.findById(id) | 344 | return UserModel.findByPk(id) |
345 | } | 345 | } |
346 | 346 | ||
347 | static loadByUsername (username: string) { | 347 | static loadByUsername (username: string) { |
diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts index dda57a8ba..49f82023b 100644 --- a/server/models/activitypub/actor.ts +++ b/server/models/activitypub/actor.ts | |||
@@ -265,7 +265,7 @@ export class ActorModel extends Model<ActorModel> { | |||
265 | VideoChannel: VideoChannelModel | 265 | VideoChannel: VideoChannelModel |
266 | 266 | ||
267 | static load (id: number) { | 267 | static load (id: number) { |
268 | return ActorModel.unscoped().findById(id) | 268 | return ActorModel.unscoped().findByPk(id) |
269 | } | 269 | } |
270 | 270 | ||
271 | static loadAccountActorByVideoId (videoId: number, transaction: Sequelize.Transaction) { | 271 | static loadAccountActorByVideoId (videoId: number, transaction: Sequelize.Transaction) { |
diff --git a/server/models/video/video-change-ownership.ts b/server/models/video/video-change-ownership.ts index 48c07728f..85e688c4f 100644 --- a/server/models/video/video-change-ownership.ts +++ b/server/models/video/video-change-ownership.ts | |||
@@ -110,7 +110,7 @@ export class VideoChangeOwnershipModel extends Model<VideoChangeOwnershipModel> | |||
110 | } | 110 | } |
111 | 111 | ||
112 | static load (id: number) { | 112 | static load (id: number) { |
113 | return VideoChangeOwnershipModel.scope(ScopeNames.FULL).findById(id) | 113 | return VideoChangeOwnershipModel.scope(ScopeNames.FULL).findByPk(id) |
114 | } | 114 | } |
115 | 115 | ||
116 | toFormattedJSON (): VideoChangeOwnership { | 116 | toFormattedJSON (): VideoChangeOwnership { |
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 91dd0440c..2426b3de6 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts | |||
@@ -320,7 +320,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> { | |||
320 | static loadByIdAndPopulateAccount (id: number) { | 320 | static loadByIdAndPopulateAccount (id: number) { |
321 | return VideoChannelModel.unscoped() | 321 | return VideoChannelModel.unscoped() |
322 | .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) | 322 | .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) |
323 | .findById(id) | 323 | .findByPk(id) |
324 | } | 324 | } |
325 | 325 | ||
326 | static loadByIdAndAccount (id: number, accountId: number) { | 326 | static loadByIdAndAccount (id: number, accountId: number) { |
@@ -339,7 +339,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> { | |||
339 | static loadAndPopulateAccount (id: number) { | 339 | static loadAndPopulateAccount (id: number) { |
340 | return VideoChannelModel.unscoped() | 340 | return VideoChannelModel.unscoped() |
341 | .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) | 341 | .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ]) |
342 | .findById(id) | 342 | .findByPk(id) |
343 | } | 343 | } |
344 | 344 | ||
345 | static loadByUUIDAndPopulateAccount (uuid: string) { | 345 | static loadByUUIDAndPopulateAccount (uuid: string) { |
@@ -439,7 +439,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> { | |||
439 | 439 | ||
440 | return VideoChannelModel.unscoped() | 440 | return VideoChannelModel.unscoped() |
441 | .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT, ScopeNames.WITH_VIDEOS ]) | 441 | .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT, ScopeNames.WITH_VIDEOS ]) |
442 | .findById(id, options) | 442 | .findByPk(id, options) |
443 | } | 443 | } |
444 | 444 | ||
445 | toFormattedJSON (): VideoChannel { | 445 | toFormattedJSON (): VideoChannel { |
diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts index 7d1e371b9..b861b0704 100644 --- a/server/models/video/video-file.ts +++ b/server/models/video/video-file.ts | |||
@@ -117,7 +117,7 @@ export class VideoFileModel extends Model<VideoFileModel> { | |||
117 | ] | 117 | ] |
118 | } | 118 | } |
119 | 119 | ||
120 | return VideoFileModel.findById(id, options) | 120 | return VideoFileModel.findByPk(id, options) |
121 | } | 121 | } |
122 | 122 | ||
123 | static async getStats () { | 123 | static async getStats () { |
diff --git a/server/models/video/video-import.ts b/server/models/video/video-import.ts index c723e57c0..9bc0f17f5 100644 --- a/server/models/video/video-import.ts +++ b/server/models/video/video-import.ts | |||
@@ -115,7 +115,7 @@ export class VideoImportModel extends Model<VideoImportModel> { | |||
115 | } | 115 | } |
116 | 116 | ||
117 | static loadAndPopulateVideo (id: number) { | 117 | static loadAndPopulateVideo (id: number) { |
118 | return VideoImportModel.findById(id) | 118 | return VideoImportModel.findByPk(id) |
119 | } | 119 | } |
120 | 120 | ||
121 | static listUserVideoImportsForApi (userId: number, start: number, count: number, sort: string) { | 121 | static listUserVideoImportsForApi (userId: number, start: number, count: number, sort: string) { |
diff --git a/server/models/video/video-streaming-playlist.ts b/server/models/video/video-streaming-playlist.ts index bf6f7b0c4..e489f9b0e 100644 --- a/server/models/video/video-streaming-playlist.ts +++ b/server/models/video/video-streaming-playlist.ts | |||
@@ -110,7 +110,7 @@ export class VideoStreamingPlaylistModel extends Model<VideoStreamingPlaylistMod | |||
110 | ] | 110 | ] |
111 | } | 111 | } |
112 | 112 | ||
113 | return VideoStreamingPlaylistModel.findById(id, options) | 113 | return VideoStreamingPlaylistModel.findByPk(id, options) |
114 | } | 114 | } |
115 | 115 | ||
116 | static getHlsPlaylistFilename (resolution: number) { | 116 | static getHlsPlaylistFilename (resolution: number) { |
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index fe81fab1a..4516b9c7b 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -1313,7 +1313,7 @@ export class VideoModel extends Model<VideoModel> { | |||
1313 | 1313 | ||
1314 | static loadWithFiles (id: number, t?: Sequelize.Transaction, logging?: boolean) { | 1314 | static loadWithFiles (id: number, t?: Sequelize.Transaction, logging?: boolean) { |
1315 | return VideoModel.scope([ ScopeNames.WITH_FILES, ScopeNames.WITH_STREAMING_PLAYLISTS ]) | 1315 | return VideoModel.scope([ ScopeNames.WITH_FILES, ScopeNames.WITH_STREAMING_PLAYLISTS ]) |
1316 | .findById(id, { transaction: t, logging }) | 1316 | .findByPk(id, { transaction: t, logging }) |
1317 | } | 1317 | } |
1318 | 1318 | ||
1319 | static loadByUUIDWithFile (uuid: string) { | 1319 | static loadByUUIDWithFile (uuid: string) { |
diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts index 8a9ced7c1..04a3eb97c 100644 --- a/server/tests/api/check-params/user-subscriptions.ts +++ b/server/tests/api/check-params/user-subscriptions.ts | |||
@@ -212,7 +212,7 @@ describe('Test user subscriptions API validators', function () { | |||
212 | }) | 212 | }) |
213 | }) | 213 | }) |
214 | 214 | ||
215 | describe('When checking if subscriptions exist', async function () { | 215 | describe('When checking if subscriptions exist', function () { |
216 | const existPath = path + '/exist' | 216 | const existPath = path + '/exist' |
217 | 217 | ||
218 | it('Should fail with a non authenticated user', async function () { | 218 | it('Should fail with a non authenticated user', async function () { |
diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts index f8f16f54f..164905651 100644 --- a/server/tests/api/server/email.ts +++ b/server/tests/api/server/email.ts | |||
@@ -142,7 +142,8 @@ describe('Test emails', function () { | |||
142 | }) | 142 | }) |
143 | }) | 143 | }) |
144 | 144 | ||
145 | describe('When blocking/unblocking user', async function () { | 145 | describe('When blocking/unblocking user', function () { |
146 | |||
146 | it('Should send the notification email when blocking a user', async function () { | 147 | it('Should send the notification email when blocking a user', async function () { |
147 | this.timeout(10000) | 148 | this.timeout(10000) |
148 | 149 | ||
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts index ad4c87c73..80f54b7ad 100644 --- a/server/tests/api/server/follows.ts +++ b/server/tests/api/server/follows.ts | |||
@@ -241,7 +241,7 @@ describe('Test follows', function () { | |||
241 | expect(res.body.data[0].name).to.equal('server3') | 241 | expect(res.body.data[0].name).to.equal('server3') |
242 | }) | 242 | }) |
243 | 243 | ||
244 | describe('Should propagate data on a new following', async function () { | 244 | describe('Should propagate data on a new following', function () { |
245 | let video4: Video | 245 | let video4: Video |
246 | 246 | ||
247 | before(async function () { | 247 | before(async function () { |
@@ -7488,10 +7488,10 @@ send@0.16.2: | |||
7488 | range-parser "~1.2.0" | 7488 | range-parser "~1.2.0" |
7489 | statuses "~1.4.0" | 7489 | statuses "~1.4.0" |
7490 | 7490 | ||
7491 | sequelize-typescript@0.6.6: | 7491 | sequelize-typescript@0.6.7: |
7492 | version "0.6.6" | 7492 | version "0.6.7" |
7493 | resolved "https://registry.yarnpkg.com/sequelize-typescript/-/sequelize-typescript-0.6.6.tgz#926037b542dae9f4eff20609d095cc5e3a3640f3" | 7493 | resolved "https://registry.yarnpkg.com/sequelize-typescript/-/sequelize-typescript-0.6.7.tgz#372be979cbae060c554fdbaf2c2d8c93a0283303" |
7494 | integrity sha512-WGJTaNuHyYwUM8itxZvMVLeNEb7xSjisbVN1Q5rxLaIf2w67Xaf1GX6Jb+9840bjcNPvMsKgC2aR88zmw7UlcQ== | 7494 | integrity sha512-ae21Gq9VOVXlIjnh2vLdL42Kev6r4LC82xOQ2fXo0lHzQvjFeH8/GaWUlpvYv57AOgc+ZnElbYFbSLKdT9ue0w== |
7495 | dependencies: | 7495 | dependencies: |
7496 | "@types/bluebird" "3.5.18" | 7496 | "@types/bluebird" "3.5.18" |
7497 | "@types/node" "6.0.41" | 7497 | "@types/node" "6.0.41" |
@@ -7499,10 +7499,10 @@ sequelize-typescript@0.6.6: | |||
7499 | es6-shim "0.35.3" | 7499 | es6-shim "0.35.3" |
7500 | glob "7.1.2" | 7500 | glob "7.1.2" |
7501 | 7501 | ||
7502 | sequelize@4.41.2: | 7502 | sequelize@4.42.0: |
7503 | version "4.41.2" | 7503 | version "4.42.0" |
7504 | resolved "https://registry.yarnpkg.com/sequelize/-/sequelize-4.41.2.tgz#bb9ba30d72e9eeb883c9861cd0e2cac672010883" | 7504 | resolved "https://registry.yarnpkg.com/sequelize/-/sequelize-4.42.0.tgz#439467ba7bfe7d5afcc56d62b3e091860fbf18f3" |
7505 | integrity sha512-8vPf2R0o9iEmtzkqNzwFdblO+0Mu+RNxOdLeYGGqWGlp3cushLpQucAeSGPQgf2hQVZP5yOCM1ouZKTQ5FTlvA== | 7505 | integrity sha512-qxAYnX4rcv7PbNtEidb56REpxNJCdbN0qyk1jb3+e6sE7OrmS0nYMU+MFVbNTJtZfSpOEEL1TX0TkMw+wzZBxg== |
7506 | dependencies: | 7506 | dependencies: |
7507 | bluebird "^3.5.0" | 7507 | bluebird "^3.5.0" |
7508 | cls-bluebird "^2.1.0" | 7508 | cls-bluebird "^2.1.0" |