Skip to content

Commit 353e9da

Browse files
author
Leszek Wiesner
authored
4.1.1.: Video relevance fixes (#350)
1 parent 03d4e5c commit 353e9da

16 files changed

Lines changed: 117 additions & 62 deletions

File tree

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# 4.1.1
2+
3+
## Affected components:
4+
- Processor (non-breaking changes)
5+
- GraphQL server (non-breaking changes)
6+
7+
## Bug Fixes:
8+
- Fixed video relevance calculation algorithm by:
9+
- Ignoring `publishedBeforeJoystream` date if it's in the future,
10+
- Fixing a bug with Joystream/YT creation weight formula,
11+
- Introduced an age limit of 365 days to prevent negative relevance score
12+
- Fixed ineffective `videoRelevanceManager` calls in GraphQL server due to `videoRelevanceManager` not being turned on.
13+
- Fixed a bug causing both GraphQL server and Processor services to run video relevance and language update loops (which only processor should be running)
14+
- Fixed imports in GraphQl server and Processor by moving shared utilities to root `utils` directory to prevent mix-ups.
15+
16+
117
# 4.1.0
218

319
## Affected components:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "orion",
3-
"version": "4.1.0",
3+
"version": "4.1.1",
44
"engines": {
55
"node": ">=16"
66
},

src/mappings/content/commentsAndReactions.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,9 @@ import {
5353
commentCountersManager,
5454
videoRelevanceManager,
5555
} from '../utils'
56-
import {
57-
getAccountForMember,
58-
getChannelOwnerMemberByChannelId,
59-
memberHandleById,
60-
parseVideoTitle,
61-
} from './utils'
56+
import { getAccountForMember, getChannelOwnerMemberByChannelId, memberHandleById } from './utils'
6257
import { addNotification } from '../../utils/notification'
58+
import { parseVideoTitle } from '../../utils/notification/helpers'
6359

6460
function parseVideoReaction(reaction: ReactVideo.Reaction): VideoReactionOptions {
6561
const protobufReactionToGraphqlReaction = {

src/mappings/content/nft.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ import {
5353
notifyBiddersOnAuctionCompletion,
5454
notifyChannelFollowers,
5555
parseContentActor,
56-
parseVideoTitle,
5756
processNft,
5857
} from './utils'
58+
import { parseVideoTitle } from '../../utils/notification/helpers'
5959

6060
export async function processOpenAuctionStartedEvent({
6161
overlay,

src/mappings/content/utils.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ import { criticalError } from '../../utils/misc'
7575
import { addNotification } from '../../utils/notification'
7676
import { EntityManagerOverlay, Flat } from '../../utils/overlay'
7777
import { addNftActivity, addNftHistoryEntry, genericEventFields, invalidMetadata } from '../utils'
78+
import { parseChannelTitle, parseVideoTitle } from '../../utils/notification/helpers'
7879

7980
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8081
export type AsDecoded<MetaClass> = MetaClass extends { create: (props?: infer I) => any }
@@ -887,14 +888,6 @@ export function increaseChannelCumulativeRevenue(channel: Flat<Channel>, amount:
887888
channel.cumulativeRevenue = (channel.cumulativeRevenue || 0n) + amount
888889
}
889890

890-
export function parseChannelTitle(channel: Flat<Channel>): string {
891-
return channel.title || FALLBACK_CHANNEL_TITLE
892-
}
893-
894-
export function parseVideoTitle(video: Flat<Video>): string {
895-
return video.title || FALLBACK_VIDEO_TITLE
896-
}
897-
898891
export async function memberHandleById(
899892
overlay: EntityManagerOverlay,
900893
memberId: string
@@ -908,6 +901,3 @@ export async function getChannelTitleById(overlay: EntityManagerOverlay, channel
908901
const channel = await overlay.getRepository(Channel).getByIdOrFail(channelId)
909902
return parseChannelTitle(channel)
910903
}
911-
912-
export const FALLBACK_CHANNEL_TITLE = '??'
913-
export const FALLBACK_VIDEO_TITLE = '??'

src/mappings/content/video.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@ import {
2929
deleteVideo,
3030
encodeAssets,
3131
notifyChannelFollowers,
32-
parseChannelTitle,
3332
parseContentActor,
34-
parseVideoTitle,
3533
processAppActionMetadata,
3634
processNft,
3735
} from './utils'
36+
import { parseChannelTitle, parseVideoTitle } from '../../utils/notification/helpers'
3837

3938
export async function processVideoCreatedEvent({
4039
overlay,

src/mappings/token/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { getCurrentBlockHeight } from '../../utils/blockHeight'
4545
import { EventHandlerContext } from '../../utils/events'
4646
import { criticalError } from '../../utils/misc'
4747
import { addNotification } from '../../utils/notification'
48-
import { getChannelOwnerAccount, notifyChannelFollowers, parseChannelTitle } from '../content/utils'
48+
import { getChannelOwnerAccount, notifyChannelFollowers } from '../content/utils'
4949
import { deserializeMetadata, genericEventFields } from '../utils'
5050
import {
5151
VestingScheduleData,
@@ -60,6 +60,7 @@ import {
6060
processTokenMetadata,
6161
processValidatedTransfers,
6262
} from './utils'
63+
import { parseChannelTitle } from '../../utils/notification/helpers'
6364

6465
export async function processTokenIssuedEvent({
6566
overlay,

src/mappings/utils.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,6 @@ import { OrionVideoLanguageManager } from '../utils/OrionVideoLanguageManager'
1515
export const orionVideoLanguageManager = new OrionVideoLanguageManager()
1616
export const commentCountersManager = new CommentCountersManager()
1717
export const videoRelevanceManager = new VideoRelevanceManager()
18-
// eslint-disable-next-line no-void
19-
void orionVideoLanguageManager.init(
20-
1000 * 60 * 5 // 5 mins
21-
)
22-
// eslint-disable-next-line no-void
23-
void videoRelevanceManager.init({
24-
fullUpdateLoopTime: 1000 * 60 * 60 * 12, // 12 hrs
25-
scheduledUpdateLoopTime: 1000 * 60 * 10, // 10 mins
26-
})
2718
export const JOYSTREAM_SS58_PREFIX = 126
2819

2920
export function bytesToString(b: Uint8Array): string {

src/processor.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,11 @@ import {
113113
processUpcomingTokenSaleUpdatedEvent,
114114
processUserParticipatedInSplitEvent,
115115
} from './mappings/token'
116-
import { commentCountersManager, videoRelevanceManager } from './mappings/utils'
116+
import {
117+
commentCountersManager,
118+
videoRelevanceManager,
119+
orionVideoLanguageManager,
120+
} from './mappings/utils'
117121
import { Event } from './types/support'
118122
import { EventHandler, EventInstance, EventNames, eventConstructors } from './utils/events'
119123
import { assertAssignable } from './utils/misc'
@@ -363,6 +367,25 @@ async function afterDbUpdate(em: EntityManager) {
363367
}
364368

365369
const offchainState = new OffchainState()
370+
371+
// Initialize update intervals
372+
orionVideoLanguageManager
373+
.init(
374+
1000 * 60 * 5 // 5 mins
375+
)
376+
.catch((e) => {
377+
throw new Error(`Failed to initialize Orion video language manager: ${e.toString()}`)
378+
})
379+
380+
videoRelevanceManager
381+
.init({
382+
fullUpdateLoopTime: 1000 * 60 * 60 * 12, // 12 hrs
383+
scheduledUpdateLoopTime: 1000 * 60 * 10, // 10 mins
384+
})
385+
.catch((e) => {
386+
throw new Error(`Failed to initialize Orion video relevance manager: ${e.toString()}`)
387+
})
388+
366389
let exportBlockNumber: number
367390

368391
processor.run(new TypeormDatabase({ isolationLevel: 'READ COMMITTED' }), async (ctx) => {

src/server-extension/resolvers/AdminResolver/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import { GraphQLResolveInfo } from 'graphql'
1111
import 'reflect-metadata'
1212
import { Args, Ctx, Info, Int, Mutation, Query, Resolver, UseMiddleware } from 'type-graphql'
1313
import { EntityManager, In, Not, UpdateResult } from 'typeorm'
14-
import { parseVideoTitle } from '../../../mappings/content/utils'
15-
import { videoRelevanceManager } from '../../../mappings/utils'
1614
import {
1715
Account,
1816
Channel,
@@ -76,6 +74,8 @@ import {
7674
VideoWeights,
7775
} from './types'
7876
import { processCommentsCensorshipStatusUpdate } from './utils'
77+
import { recalculateAllVideosRelevance } from '../../utils'
78+
import { parseVideoTitle } from '../../../utils/notification/helpers'
7979

8080
@Resolver()
8181
export class AdminResolver {
@@ -161,7 +161,7 @@ export class AdminResolver {
161161
],
162162
em
163163
)
164-
await videoRelevanceManager.updateVideoRelevanceValue(em, true)
164+
await recalculateAllVideosRelevance(em)
165165
return { isApplied: true }
166166
}
167167

@@ -222,7 +222,7 @@ export class AdminResolver {
222222
}
223223
)
224224

225-
await videoRelevanceManager.updateVideoRelevanceValue(em, true)
225+
await recalculateAllVideosRelevance(em)
226226

227227
// Push the result into the results array
228228
results.push({

0 commit comments

Comments
 (0)