I exclusively worked on this issue this week #3464.
Update Feed in parser
to use Supabase:
I basically removed all invalid
and flagged
feed from src/api/parser/utils/storage
and create functions that would take care of invalidating/flagging feeds using Supabase in src/api/parser/utils/supabase.js
. Looking back, it wasn't that hard but it was quite lengthy.
The difficulty was that this function uses isFlagged
function to check flagged feed and now it talks to Supabase instead of Redis which made unit test not pass without mocking it.
addFeed: async (feed) => {
// Check if feed being added already exists in flagged feeds set
// If it is, do nothing
if (await isFlagged(feed.id)) return;
const key = createFeedKey(feed.id);
await redis
.multi()
.hset(
key,
'id',
// ...
},
So I literally created a mock for Supabase database though I had a problem with telling Jest to use the mock module.
Originally, I imported the mock this way
jest.mock('../src/utils/supabase');
const { __setMockFeeds, __resetMockFeeds } = require('../src/__mocks__/utils/supabase');
So, __setMockFeeds
would add the array to the actual module => not the mock factory that Jest uses. Those 2 are different javascript objects and Jerry helped me understand this.
// Correct way to mock
jest.mock('../src/utils/supabase');
const { __setMockFeeds, __resetMockFeeds } = require('../src/utils/supabase');
I also had to reworked the parser e2e test, now it looks even simpler. For some reason, I kept forgetting to do pnpm migrate
and I was stuck on the test for a while. I managed to make it work a few hours before 3.0 release haha.
However, work is not yet done, Supabase doesn't really work in production, parser
can't really talk to the database, I hope to fix this soon and earn myself some peace of mind.
Top comments (0)