ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix video views
Chocobozzz63dc589865fa
diff --git a/server/initializers/constants.ts b/server/initializers/constants.tsindex 62778ae584..b5f8fc0bc7 100644--- a/server/initializers/constants.ts+++ b/server/initializers/constants.ts@@ -14,7 +14,7 @@ import { CONFIG, registerConfigChangedHandler } from './config'// ----------------------------------------------------------------------------const LAST_MIGRATION_VERSION = 375+const LAST_MIGRATION_VERSION = 380// ---------------------------------------------------------------------------diff --git a/server/initializers/migrations/0380-cleanup-timestamps.ts b/server/initializers/migrations/0380-cleanup-timestamps.tsnew file mode 100644index 0000000000..2a9fd6f02a--- /dev/null+++ b/server/initializers/migrations/0380-cleanup-timestamps.ts@@ -0,0 +1,29 @@+import * as Sequelize from 'sequelize'++async function up (utils: {+ transaction: Sequelize.Transaction,+ queryInterface: Sequelize.QueryInterface,+ sequelize: Sequelize.Sequelize,+ db: any+}): Promise<void> {+ try {+ await utils.queryInterface.removeColumn('application', 'createdAt')+ } catch { /* the column could not exist */ }++ try {+ await utils.queryInterface.removeColumn('application', 'updatedAt')+ } catch { /* the column could not exist */ }++ try {+ await utils.queryInterface.removeColumn('videoView', 'updatedAt')+ } catch { /* the column could not exist */ }+}++function down (options) {+ throw new Error('Not implemented.')+}++export {+ up,+ down+}diff --git a/server/lib/job-queue/handlers/video-views.ts b/server/lib/job-queue/handlers/video-views.tsindex fa1fd13b38..73fa5ed041 100644--- a/server/lib/job-queue/handlers/video-views.ts+++ b/server/lib/job-queue/handlers/video-views.ts@@ -27,6 +27,12 @@ async function processVideosViews () {logger.debug('Adding %d views to video %d in hour %d.', views, videoId, hour)try {+ const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId)+ if (!video) {+ logger.debug('Video %d does not exist anymore, skipping videos view addition.', videoId)+ continue+ }+await VideoViewModel.create({startDate,endDate,@@ -34,7 +40,6 @@ async function processVideosViews () {videoId})- const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId)if (video.isOwned()) {// If this is a remote video, the origin instance will send us an updateawait VideoModel.incrementViews(videoId, views)@@ -44,13 +49,13 @@ async function processVideosViews () {await federateVideoIfNeeded(video, false)}} catch (err) {- logger.debug('Cannot create video views for video %d in hour %d. Maybe the video does not exist anymore?', videoId, hour)+ logger.error('Cannot create video views for video %d in hour %d.', videoId, hour, { err })}}await Redis.Instance.deleteVideoViews(videoId, hour)} catch (err) {- logger.error('Cannot update video views of video %d in hour %d.', videoId, hour)+ logger.error('Cannot update video views of video %d in hour %d.', videoId, hour, { err })}}}