MCPcopy Create free account
hub / github.com/code100x/daily-code / scrapeData

Function scrapeData

apps/web/lib/search.ts:18–48  ·  view source on GitHub ↗
({ trackId }: { trackId: string })

Source from the content-addressed store, hash-verified

16const VECTOR_SIZE = parseInt(process.env.VECTOR_SIZE!) || 768;
17
18export async function scrapeData({ trackId }: { trackId: string }) {
19 const notion = getNotionClient();
20 const track = await getTrack(trackId);
21 const data = await Promise.all(
22 track?.problems.map(async (problem: any) => {
23 const notionDocId = problem.notionDocId;
24 const notionPage = await fetchNotionPage(notion, notionDocId);
25 const titles = Object.values<any>(notionPage?.block ?? {})
26 .map((block) => {
27 const title = block?.value?.properties?.title;
28 if (title && title[0] && title[0][0]) {
29 return title[0][0];
30 } else {
31 const source = block?.value?.properties?.source;
32 if (source && source[0] && source[0][0]) {
33 return source[0][0];
34 } else {
35 return null;
36 }
37 }
38 })
39 .filter((title) => title);
40 problem["titles"] = titles.flat().join(" ");
41 problem["trackId"] = track.id;
42 problem["trackTitle"] = track.title;
43 problem["image"] = track.image;
44 return problem;
45 }) || []
46 );
47 return data;
48}
49
50export async function createCollection(){
51 await client.createCollection("DailyCode",{

Callers 1

insertDataFunction · 0.85

Calls 1

getTrackFunction · 0.90

Tested by

no test coverage detected