|
@@ -8,12 +8,10 @@ import { DecodedMetadataObject } from '@joystream/metadata-protobuf/types'
|
|
import { integrateMeta } from '@joystream/metadata-protobuf/utils'
|
|
import { integrateMeta } from '@joystream/metadata-protobuf/utils'
|
|
import { Channel, Video, VideoViewEvent } from '../../model'
|
|
import { Channel, Video, VideoViewEvent } from '../../model'
|
|
import { EventHandlerContext } from '../../utils/events'
|
|
import { EventHandlerContext } from '../../utils/events'
|
|
-import { deserializeMetadata, u8aToBytes } from '../utils'
|
|
|
|
|
|
+import { deserializeMetadata, u8aToBytes, videoRelevanceManager } from '../utils'
|
|
import { processVideoMetadata } from './metadata'
|
|
import { processVideoMetadata } from './metadata'
|
|
import { deleteVideo, encodeAssets, processAppActionMetadata, processNft } from './utils'
|
|
import { deleteVideo, encodeAssets, processAppActionMetadata, processNft } from './utils'
|
|
import { generateAppActionCommitment } from '@joystream/js/utils'
|
|
import { generateAppActionCommitment } from '@joystream/js/utils'
|
|
-import { config, ConfigVariable } from '../../utils/config'
|
|
|
|
-import { NEWNESS_SECONDS_DIVIDER } from '../../utils/VideoRelevanceManager'
|
|
|
|
|
|
|
|
export async function processVideoCreatedEvent({
|
|
export async function processVideoCreatedEvent({
|
|
overlay,
|
|
overlay,
|
|
@@ -28,10 +26,6 @@ export async function processVideoCreatedEvent({
|
|
|
|
|
|
const videoId = contentId.toString()
|
|
const videoId = contentId.toString()
|
|
const viewsNum = await overlay.getEm().getRepository(VideoViewEvent).countBy({ videoId })
|
|
const viewsNum = await overlay.getEm().getRepository(VideoViewEvent).countBy({ videoId })
|
|
- const [newnessWeight, viewsWeight] = await config.get(
|
|
|
|
- ConfigVariable.RelevanceWeights,
|
|
|
|
- overlay.getEm()
|
|
|
|
- )
|
|
|
|
const video = overlay.getRepository(Video).new({
|
|
const video = overlay.getRepository(Video).new({
|
|
id: videoId,
|
|
id: videoId,
|
|
createdAt: new Date(block.timestamp),
|
|
createdAt: new Date(block.timestamp),
|
|
@@ -46,13 +40,11 @@ export async function processVideoCreatedEvent({
|
|
reactionsCount: 0,
|
|
reactionsCount: 0,
|
|
viewsNum,
|
|
viewsNum,
|
|
// First we need to dic by 1k to match postgres epoch (in seconds) then apply the further dividers
|
|
// First we need to dic by 1k to match postgres epoch (in seconds) then apply the further dividers
|
|
- videoRelevance: +(
|
|
|
|
- (30 - (Date.now() - new Date(block.timestamp).getTime()) / (1000 * NEWNESS_SECONDS_DIVIDER)) *
|
|
|
|
- newnessWeight +
|
|
|
|
- viewsNum * viewsWeight
|
|
|
|
- ).toFixed(2),
|
|
|
|
|
|
+ videoRelevance: 0,
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+ videoRelevanceManager.scheduleRecalcForVideo(videoId)
|
|
|
|
+
|
|
// fetch related channel and owner
|
|
// fetch related channel and owner
|
|
const channel = await overlay.getRepository(Channel).getByIdOrFail(channelId.toString())
|
|
const channel = await overlay.getRepository(Channel).getByIdOrFail(channelId.toString())
|
|
|
|
|
|
@@ -140,6 +132,10 @@ export async function processVideoUpdatedEvent({
|
|
}
|
|
}
|
|
|
|
|
|
if (videoMetadataUpdate) {
|
|
if (videoMetadataUpdate) {
|
|
|
|
+ if ('publishedBeforeJoystream' in videoMetadataUpdate) {
|
|
|
|
+ delete videoMetadataUpdate.publishedBeforeJoystream
|
|
|
|
+ }
|
|
|
|
+
|
|
await processVideoMetadata(
|
|
await processVideoMetadata(
|
|
overlay,
|
|
overlay,
|
|
block,
|
|
block,
|