(trackId: string)
| 54 | } |
| 55 | |
| 56 | export async function insertData(trackId: string) { |
| 57 | const data = await scrapeData({ trackId }); |
| 58 | data.forEach(async (problem) => { |
| 59 | const response = await model.embedContent(problem.titles); |
| 60 | problem.vector = response.embedding.values.slice(0, VECTOR_SIZE); |
| 61 | await client.upsert("DailyCode", { |
| 62 | wait: true, |
| 63 | points: [ |
| 64 | { |
| 65 | id: randomUUID(), |
| 66 | vector: problem.vector, |
| 67 | payload: { |
| 68 | trackId: problem.trackId, |
| 69 | trackTitle: problem.trackTitle, |
| 70 | image: problem.image, |
| 71 | problemTitle: problem.title, |
| 72 | problemId: problem.id, |
| 73 | }, |
| 74 | }, |
| 75 | ], |
| 76 | }); |
| 77 | }); |
| 78 | await db.track.update({ |
| 79 | where: { |
| 80 | id: trackId, |
| 81 | }, |
| 82 | data: { |
| 83 | inSearch: true, |
| 84 | }, |
| 85 | }); |
| 86 | } |
| 87 | |
| 88 | export async function getSearchResults(query: string) { |
| 89 | const vector = await model.embedContent(query); |
no test coverage detected