-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🧧 Recommendations #325
base: master
Are you sure you want to change the base?
🧧 Recommendations #325
Conversation
# Conflicts: # .env # Makefile # db/migrations/1704717446430-Data.js # package-lock.json # package.json # src/mappings/content/channel.ts # src/mappings/content/video.ts # src/processor.ts # src/server-extension/resolvers/VideosResolver/index.ts # src/server-extension/resolvers/VideosResolver/types.ts # src/utils/language.ts
// setup item properties | ||
const itemPropertiesReqs = Object.entries(itemPropToType).map( | ||
([propName, type]) => new requests.AddItemProperty(propName, type) | ||
) | ||
|
||
// setup segments | ||
const segmentsReqs = new requests.CreatePropertyBasedSegmentation( | ||
'channel-segmentation', | ||
'items', | ||
'channel_id' | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shoudn't there be a check before creating properties to ensure that the properties does not already exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recombee will just return 409 if a property is already created
|
||
if (user && !userId) { | ||
recommendationServiceManager.scheduleUserUpsert({ id: user.id }) | ||
} | ||
|
||
if (!user) { | ||
throw new UnauthorizedError('User not found by provided userId') | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (user && !userId) { | |
recommendationServiceManager.scheduleUserUpsert({ id: user.id }) | |
} | |
if (!user) { | |
throw new UnauthorizedError('User not found by provided userId') | |
} | |
if (!user) { | |
throw new UnauthorizedError('User not found by provided userId') | |
} | |
recommendationServiceManager.scheduleUserUpsert({ id: user.id }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the goal here was to not upsert the same anonymous user each time they enter the Atlas.
- No user ID in req - new user
- User ID in req - old anonymous user that is just looking for a new cookie
// recommendationServiceManager.scheduleClickEvent( | ||
// `${itemId}-video`, | ||
// session.userId, | ||
// duration, | ||
// recommId | ||
// ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this code block is commented out?
}) | ||
await row.save() | ||
|
||
// recommendationServiceManager.scheduleItemConsumed(`${itemId}-video`, session.userId, recommId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this is commented out?
// recommendationServiceManager.scheduleViewPortion( | ||
// `${itemId}-video`, | ||
// session.userId, | ||
// portion, | ||
// recommId | ||
// ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this code block is commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, is there a need for this handler since video rating is being set from processVideoReaction
mapping>
private async _batchUpdateLoop(intervalMs: number): Promise<void> { | ||
while (true) { | ||
if (this._queue.length) { | ||
const batchArray = [...this._queue] | ||
this._queue.length = 0 | ||
await this.sendBatchRequest(batchArray) | ||
} | ||
await new Promise((resolve) => setTimeout(resolve, intervalMs)) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, a general implementation problem with this approach is that you are not persisting the items/interactions pushed to the queue(it's all in-memory). So, if sendBatchRequest
fails or the process (Graphql Server, processor or Auth-API) fails with some elements in the queue, the elements will be lost forever.
Fix
I would suggest you go with some persistent queue options.
After we make a switch we can make sure to start only interactions API when both variables are present. Now we need to launch these services even if Recombee cannot be setup, BCS of mongo db interactions.
|
No description provided.