From 4dd4bdb7f1e053d1b4d51ca3ec270603c206d516 Mon Sep 17 00:00:00 2001 From: VasN Date: Tue, 10 Mar 2026 16:03:38 +0530 Subject: [PATCH] fix: skip lofn for My Feed time-ordered feed, use chronological config When My Feed is ordered by date, serve a simple chronological feed using FeedPreferencesConfigGenerator with CustomFeedNaV1 config instead of routing through lofn. This removes the lofn roundtrip, uses the chronological retriever, disables engagement filter, and applies all user preferences directly. --- __tests__/feeds.ts | 12 +++-------- __tests__/integrations/feed.ts | 32 +++++++++++++++++++++++++++++ src/integrations/feed/generators.ts | 14 +++++++------ 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/__tests__/feeds.ts b/__tests__/feeds.ts index 9a3e043d39..713607a794 100644 --- a/__tests__/feeds.ts +++ b/__tests__/feeds.ts @@ -1073,19 +1073,13 @@ describe('query feed', () => { expect(res.data.feed.edges.length).toEqual(1); }); - it('should return feed v2 with TIME ranking', async () => { + it('should return feed v2 with TIME ranking using chronological config', async () => { loggedUser = '1'; - nock('http://localhost:6002') - .post('/config') - .reply(200, { - user_id: '1', - config: { - providers: {}, - }, - }); nock('http://localhost:6000') .post('/feed.json', (body) => { + expect(body.feed_config_name).toBe('custom_feed_na_v1'); expect(body.order_by).toBe(FeedOrderBy.Date); + expect(body.disable_engagement_filter).toBe(true); return true; }) .reply(200, { diff --git a/__tests__/integrations/feed.ts b/__tests__/integrations/feed.ts index 645da8824b..15870b18c5 100644 --- a/__tests__/integrations/feed.ts +++ b/__tests__/integrations/feed.ts @@ -5,7 +5,9 @@ import { FeedConfigName, FeedPreferencesConfigGenerator, FeedResponse, + versionToTimeFeedGenerator, } from '../../src/integrations/feed'; +import { FeedOrderBy } from '../../src/entity/Feed'; import { connectionFromNodes, feedCursorPageGenerator, @@ -893,3 +895,33 @@ describe('FeedLofnConfigGenerator', () => { }); }); }); + +describe('versionToTimeFeedGenerator', () => { + beforeEach(async () => { + await saveFixtures(con, Source, sourcesFixture); + await con.getRepository(Feed).save({ id: '1', userId: '1' }); + }); + + it('should generate config with chronological settings and no lofn', async () => { + let capturedBody: Record = {}; + nock('http://localhost:6000') + .post('/feed.json', (body) => { + capturedBody = body; + return true; + }) + .reply(200, { + data: [{ post_id: '1' }], + }); + + const generator = versionToTimeFeedGenerator(20); + await generator.generate(ctx, { + user_id: '1', + page_size: 10, + offset: 0, + }); + + expect(capturedBody.feed_config_name).toBe(FeedConfigName.CustomFeedNaV1); + expect(capturedBody.order_by).toBe(FeedOrderBy.Date); + expect(capturedBody.disable_engagement_filter).toBe(true); + }); +}); diff --git a/src/integrations/feed/generators.ts b/src/integrations/feed/generators.ts index 14af672ecc..53be29f238 100644 --- a/src/integrations/feed/generators.ts +++ b/src/integrations/feed/generators.ts @@ -172,16 +172,18 @@ export const versionToFeedGenerator = (version: number): FeedGenerator => { ); }; -export const versionToTimeFeedGenerator = (version: number): FeedGenerator => { +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export const versionToTimeFeedGenerator = (_version: number): FeedGenerator => { return new FeedGenerator( feedClient, - new FeedLofnConfigGenerator( - { ...baseFeedConfig, order_by: FeedOrderBy.Date }, - lofnClient, + new FeedPreferencesConfigGenerator( { - ...opts, - feed_version: version.toString() as FeedVersion, + ...baseFeedConfig, + feed_config_name: FeedConfigName.CustomFeedNaV1, + order_by: FeedOrderBy.Date, + disable_engagement_filter: true, }, + opts, ), ); };