aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/user/user.ts7
-rw-r--r--server/models/video/author.ts8
2 files changed, 13 insertions, 2 deletions
diff --git a/server/models/user/user.ts b/server/models/user/user.ts
index 12a7547f5..9bf13ad24 100644
--- a/server/models/user/user.ts
+++ b/server/models/user/user.ts
@@ -244,7 +244,7 @@ loadByUsernameOrEmail = function (username: string, email: string) {
244function getOriginalVideoFileTotalFromUser (user: UserInstance) { 244function getOriginalVideoFileTotalFromUser (user: UserInstance) {
245 const query = { 245 const query = {
246 attributes: [ 246 attributes: [
247 Sequelize.fn('COUNT', Sequelize.col('VideoFile.size'), 'totalVideoBytes') 247 Sequelize.fn('COUNT', Sequelize.col('User.Author.Video.VideoFile.size'), 'totalVideoBytes')
248 ], 248 ],
249 where: { 249 where: {
250 id: user.id 250 id: user.id
@@ -252,12 +252,15 @@ function getOriginalVideoFileTotalFromUser (user: UserInstance) {
252 include: [ 252 include: [
253 { 253 {
254 model: User['sequelize'].models.Author, 254 model: User['sequelize'].models.Author,
255 required: true,
255 include: [ 256 include: [
256 { 257 {
257 model: User['sequelize'].models.Video, 258 model: User['sequelize'].models.Video,
259 required: true,
258 include: [ 260 include: [
259 { 261 {
260 model: User['sequelize'].models.VideoFile 262 model: User['sequelize'].models.VideoFile,
263 required: true
261 } 264 }
262 ] 265 ]
263 } 266 }
diff --git a/server/models/video/author.ts b/server/models/video/author.ts
index c30cc306d..fd0f44f6b 100644
--- a/server/models/video/author.ts
+++ b/server/models/video/author.ts
@@ -71,6 +71,14 @@ function associate (models) {
71 }, 71 },
72 onDelete: 'cascade' 72 onDelete: 'cascade'
73 }) 73 })
74
75 Author.hasMany(models.Video, {
76 foreignKey: {
77 name: 'authorId',
78 allowNull: false
79 },
80 onDelete: 'cascade'
81 })
74} 82}
75 83
76findOrCreateAuthor = function (name: string, podId: number, userId: number, transaction: Sequelize.Transaction) { 84findOrCreateAuthor = function (name: string, podId: number, userId: number, transaction: Sequelize.Transaction) {