Fix video view filename
authorChocobozzz <me@florianbigard.com>
Mon, 15 Jun 2020 13:18:54 +0000 (15:18 +0200)
committerChocobozzz <me@florianbigard.com>
Mon, 15 Jun 2020 13:18:54 +0000 (15:18 +0200)
server/initializers/database.ts
server/lib/job-queue/handlers/video-views.ts
server/lib/schedulers/remove-old-views-scheduler.ts
server/models/video/video-view.ts [new file with mode: 0644]
server/models/video/video-views.ts [deleted file]
server/models/video/video.ts

index eedaf3c4eef1fa4123c3bc0c0ea9b34c68c0e623..633d4f95645eac497265a5ccb32cbd06e8448caf 100644 (file)
@@ -25,7 +25,7 @@ import { CONFIG } from './config'
 import { ScheduleVideoUpdateModel } from '../models/video/schedule-video-update'
 import { VideoCaptionModel } from '../models/video/video-caption'
 import { VideoImportModel } from '../models/video/video-import'
-import { VideoViewModel } from '../models/video/video-views'
+import { VideoViewModel } from '../models/video/video-view'
 import { VideoChangeOwnershipModel } from '../models/video/video-change-ownership'
 import { VideoRedundancyModel } from '../models/redundancy/video-redundancy'
 import { UserVideoHistoryModel } from '../models/account/user-video-history'
index 7211df237d36de81dd66d741d7f17d6c76885ff8..897235ec00d35fdfd7813cf9e658e9cce5897cba 100644 (file)
@@ -1,7 +1,7 @@
 import { Redis } from '../../redis'
 import { logger } from '../../../helpers/logger'
 import { VideoModel } from '../../../models/video/video'
-import { VideoViewModel } from '../../../models/video/video-views'
+import { VideoViewModel } from '../../../models/video/video-view'
 import { isTestInstance } from '../../../helpers/core-utils'
 import { federateVideoIfNeeded } from '../../activitypub/videos'
 
index 5ae87fe5045356f06222e2c54dbcc29869717c0c..73577a4215efae384f1a102288feb5f4db4ee28d 100644 (file)
@@ -2,7 +2,7 @@ import { logger } from '../../helpers/logger'
 import { AbstractScheduler } from './abstract-scheduler'
 import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants'
 import { CONFIG } from '../../initializers/config'
-import { VideoViewModel } from '../../models/video/video-views'
+import { VideoViewModel } from '../../models/video/video-view'
 
 export class RemoveOldViewsScheduler extends AbstractScheduler {
 
diff --git a/server/models/video/video-view.ts b/server/models/video/video-view.ts
new file mode 100644 (file)
index 0000000..40db5ef
--- /dev/null
@@ -0,0 +1,59 @@
+import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Model, Table } from 'sequelize-typescript'
+import { VideoModel } from './video'
+import * as Sequelize from 'sequelize'
+
+@Table({
+  tableName: 'videoView',
+  updatedAt: false,
+  indexes: [
+    {
+      fields: [ 'videoId' ]
+    },
+    {
+      fields: [ 'startDate' ]
+    }
+  ]
+})
+export class VideoViewModel extends Model<VideoViewModel> {
+  @CreatedAt
+  createdAt: Date
+
+  @AllowNull(false)
+  @Column(Sequelize.DATE)
+  startDate: Date
+
+  @AllowNull(false)
+  @Column(Sequelize.DATE)
+  endDate: Date
+
+  @AllowNull(false)
+  @Column
+  views: number
+
+  @ForeignKey(() => VideoModel)
+  @Column
+  videoId: number
+
+  @BelongsTo(() => VideoModel, {
+    foreignKey: {
+      allowNull: false
+    },
+    onDelete: 'CASCADE'
+  })
+  Video: VideoModel
+
+  static removeOldRemoteViewsHistory (beforeDate: string) {
+    const query = {
+      where: {
+        startDate: {
+          [Sequelize.Op.lt]: beforeDate
+        },
+        videoId: {
+          [Sequelize.Op.in]: Sequelize.literal('(SELECT "id" FROM "video" WHERE "remote" IS TRUE)')
+        }
+      }
+    }
+
+    return VideoViewModel.destroy(query)
+  }
+}
diff --git a/server/models/video/video-views.ts b/server/models/video/video-views.ts
deleted file mode 100644 (file)
index 40db5ef..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Model, Table } from 'sequelize-typescript'
-import { VideoModel } from './video'
-import * as Sequelize from 'sequelize'
-
-@Table({
-  tableName: 'videoView',
-  updatedAt: false,
-  indexes: [
-    {
-      fields: [ 'videoId' ]
-    },
-    {
-      fields: [ 'startDate' ]
-    }
-  ]
-})
-export class VideoViewModel extends Model<VideoViewModel> {
-  @CreatedAt
-  createdAt: Date
-
-  @AllowNull(false)
-  @Column(Sequelize.DATE)
-  startDate: Date
-
-  @AllowNull(false)
-  @Column(Sequelize.DATE)
-  endDate: Date
-
-  @AllowNull(false)
-  @Column
-  views: number
-
-  @ForeignKey(() => VideoModel)
-  @Column
-  videoId: number
-
-  @BelongsTo(() => VideoModel, {
-    foreignKey: {
-      allowNull: false
-    },
-    onDelete: 'CASCADE'
-  })
-  Video: VideoModel
-
-  static removeOldRemoteViewsHistory (beforeDate: string) {
-    const query = {
-      where: {
-        startDate: {
-          [Sequelize.Op.lt]: beforeDate
-        },
-        videoId: {
-          [Sequelize.Op.in]: Sequelize.literal('(SELECT "id" FROM "video" WHERE "remote" IS TRUE)')
-        }
-      }
-    }
-
-    return VideoViewModel.destroy(query)
-  }
-}
index 5aa40220ee78b892e46069564b154a9981b41a42..ae2483b2f920ee2439161f0b2fa3616941b83050 100644 (file)
@@ -76,7 +76,7 @@ import { ScheduleVideoUpdateModel } from './schedule-video-update'
 import { VideoCaptionModel } from './video-caption'
 import { VideoBlacklistModel } from './video-blacklist'
 import { remove } from 'fs-extra'
-import { VideoViewModel } from './video-views'
+import { VideoViewModel } from './video-view'
 import { VideoRedundancyModel } from '../redundancy/video-redundancy'
 import {
   videoFilesModelToFormattedJSON,