fix(plaza): correct similar recall query params
This commit is contained in:
+1
-1
@@ -404,7 +404,7 @@ export function createPlazaRecommendService(
|
||||
const recallSimilar = async (profile, userId, categorySlug) => {
|
||||
const seeds = [...profile.likedPostIds].slice(0, 12);
|
||||
if (seeds.length === 0) return [];
|
||||
const params = ['published', ...seeds];
|
||||
const params = [...seeds];
|
||||
let filter = ` AND r1.post_id IN (${seeds.map(() => '?').join(',')})`;
|
||||
if (userId) {
|
||||
filter += ' AND r2.user_id <> ?';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createPlazaEventService } from './plaza-events.mjs';
|
||||
import { recommendInternals } from './plaza-recommend.mjs';
|
||||
import { createPlazaRecommendService, recommendInternals } from './plaza-recommend.mjs';
|
||||
|
||||
test('plaza events: dwell tiers increase signal weight', () => {
|
||||
const { eventSignal } = createPlazaEventService({ query: async () => [[]] }).internals;
|
||||
@@ -64,6 +64,57 @@ test('plaza recommend: cold start interleaves categories', () => {
|
||||
assert.notEqual(ordered[0].category_slug, ordered[1].category_slug);
|
||||
});
|
||||
|
||||
test('plaza recommend: recallSimilar binds seeds before viewer id', async () => {
|
||||
let similarParams = null;
|
||||
const pool = {
|
||||
async query(sql, params) {
|
||||
if (sql.includes('FROM plaza_reactions r1')) {
|
||||
similarParams = params;
|
||||
return [[]];
|
||||
}
|
||||
if (sql.includes('SELECT tags FROM plaza_posts WHERE id IN')) {
|
||||
return [[{ tags: '[]' }]];
|
||||
}
|
||||
if (sql.includes('FROM plaza_posts pp')) {
|
||||
return [[]];
|
||||
}
|
||||
return [[]];
|
||||
},
|
||||
};
|
||||
const recommend = createPlazaRecommendService(pool, {
|
||||
eventService: {
|
||||
async getProfile() {
|
||||
return {
|
||||
categoryWeights: {},
|
||||
tagWeights: {},
|
||||
authorWeights: {},
|
||||
feedCategoryWeights: {},
|
||||
likedPostIds: new Set(['seed-post']),
|
||||
dislikedPostIds: new Set(),
|
||||
dislikedCategorySlugs: new Set(),
|
||||
followedAuthorIds: new Set(),
|
||||
seenPostIds: new Set(),
|
||||
deepSeenPostIds: new Set(),
|
||||
eventCount: 1,
|
||||
profileVersion: 7,
|
||||
};
|
||||
},
|
||||
},
|
||||
formatPostRow(row) {
|
||||
return { id: row.id };
|
||||
},
|
||||
loadViewerReactions: async () => new Map(),
|
||||
});
|
||||
|
||||
await recommend.listRecommendedFeed({
|
||||
viewerId: 'viewer-1',
|
||||
sessionId: 'session-1',
|
||||
limit: 20,
|
||||
});
|
||||
|
||||
assert.deepEqual(similarParams, ['seed-post', 'viewer-1', 80]);
|
||||
});
|
||||
|
||||
test('plaza events: dislike marks category as disliked', () => {
|
||||
const { emptyProfile } = createPlazaEventService({ query: async () => [[]] }).internals;
|
||||
const profile = emptyProfile();
|
||||
|
||||
Reference in New Issue
Block a user