Skip to content

Commit

Permalink
fix steam id conflict on scrap
Browse files Browse the repository at this point in the history
  • Loading branch information
zernonia committed Apr 11, 2022
1 parent 9225485 commit e0b1b61
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions api/steam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,17 @@ export default async (req: VercelRequest, res: VercelResponse) => {
await page.waitForNetworkIdle()
await page.waitForTimeout(500)

let data = await scrapData(page, query)
let data1 = await scrapData(page, query)

await Promise.all([page.click("#NewReleases_btn_next"), page.waitForNavigation()])
let data2 = await scrapData(page, query)

await Promise.all([page.click("#NewReleases_btn_next"), page.waitForNavigation()])
let data3 = await scrapData(page, query)

const result = await supabase.from("steam").upsert([...data, ...data2, ...data3])
const data = [...new Map([...data1, ...data2, ...data3].map((v) => [v.id, v])).values()]

const result = await supabase.from("steam").upsert(data)
if (result.error) throw new Error(result.error.message)

var hrend = process.hrtime(hrstart)
Expand Down

1 comment on commit e0b1b61

@vercel
Copy link

@vercel vercel bot commented on e0b1b61 Apr 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.