Skip to content

Commit

Permalink
fix(results): 🐛 Make sure delete all works
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Jun 20, 2022
1 parent d991dd5 commit 18c5ea5
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 32 deletions.
5 changes: 3 additions & 2 deletions apps/builder/pages/api/typebots/[typebotId]/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
}
if (req.method === 'DELETE') {
const typebotId = req.query.typebotId as string
const ids = req.query.ids as string[]
const data = req.body as { ids: string[] }
const ids = data.ids
const results = await prisma.result.deleteMany({
where: {
id: { in: ids },
id: ids.length > 0 ? { in: ids } : undefined,
typebot: canWriteTypebot(typebotId, user),
},
})
Expand Down
13 changes: 6 additions & 7 deletions apps/builder/services/typebots/results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,15 @@ export const deleteResults = async (
typebotId: string,
ids: string[]
) => {
const params = stringify(
{
ids,
workspaceId,
},
{ indices: false }
)
const params = stringify({
workspaceId,
})
return sendRequest({
url: `/api/typebots/${typebotId}/results?${params}`,
method: 'DELETE',
body: {
ids,
},
})
}

Expand Down
5 changes: 2 additions & 3 deletions packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
"main": "./index.ts",
"types": "./index.ts",
"devDependencies": {
"prisma": "^3.14.0",
"ts-node": "^10.7.0",
"prisma": "^3.15.2",
"typescript": "^4.6.4",
"dotenv-cli": "5.1.0"
},
"dependencies": {
"@prisma/client": "^3.14.0"
"@prisma/client": "^3.15.2"
},
"scripts": {
"dx": "dotenv -e ../../apps/builder/.env.local prisma db push && yarn generate:schema && yarn start:sutdio ",
Expand Down
31 changes: 29 additions & 2 deletions packages/scripts/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
import { CollaborationType, PrismaClient } from 'db'
import path from 'path'
import { migrateWorkspace } from './workspaceMigration'
const prisma = new PrismaClient({
log: [
{
emit: 'event',
level: 'query',
},
{
emit: 'stdout',
level: 'error',
},
{
emit: 'stdout',
level: 'info',
},
{
emit: 'stdout',
level: 'warn',
},
],
})

require('dotenv').config({
path: path.join(
Expand All @@ -9,7 +29,14 @@ require('dotenv').config({
})

const main = async () => {
await migrateWorkspace()
prisma.$on('query', (e) => {
console.log('Query: ' + e.query)
console.log('Params: ' + e.params)
console.log('Duration: ' + e.duration + 'ms')
})
const results =
await prisma.$queryRaw`DELETE FROM "public"."Result" WHERE "public"."Result"."typebotId"='ckzqqer3j002509l3np5x3v2y'`
console.log(results)
}

main().then()
36 changes: 18 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3751,22 +3751,22 @@
mem "^8.0.0"
php-parser "3.1.0-beta.5"

"@prisma/client@^3.14.0":
version "3.14.0"
resolved "https://registry.yarnpkg.com/@prisma/client/-/client-3.14.0.tgz#bb90405c012fcca11f4647d91153ed4c58f3bd48"
integrity sha512-atb41UpgTR1MCst0VIbiHTMw8lmXnwUvE1KyUCAkq08+wJyjRE78Due+nSf+7uwqQn+fBFYVmoojtinhlLOSaA==
"@prisma/client@^3.15.2":
version "3.15.2"
resolved "https://registry.yarnpkg.com/@prisma/client/-/client-3.15.2.tgz#2181398147afc79bfe0d83c03a88dc45b49bd365"
integrity sha512-ErqtwhX12ubPhU4d++30uFY/rPcyvjk+mdifaZO5SeM21zS3t4jQrscy8+6IyB0GIYshl5ldTq6JSBo1d63i8w==
dependencies:
"@prisma/engines-version" "3.14.0-36.2b0c12756921c891fec4f68d9444e18c7d5d4a6a"
"@prisma/engines-version" "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e"

"@prisma/engines-version@3.14.0-36.2b0c12756921c891fec4f68d9444e18c7d5d4a6a":
version "3.14.0-36.2b0c12756921c891fec4f68d9444e18c7d5d4a6a"
resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-3.14.0-36.2b0c12756921c891fec4f68d9444e18c7d5d4a6a.tgz#4edae57cf6527f35e22cebe75e49214fc0e99ac9"
integrity sha512-D+yHzq4a2r2Rrd0ZOW/mTZbgDIkUkD8ofKgusEI1xPiZz60Daks+UM7Me2ty5FzH3p/TgyhBpRrfIHx+ha20RQ==
"@prisma/engines-version@3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e":
version "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e"
resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e.tgz#bf5e2373ca68ce7556b967cb4965a7095e93fe53"
integrity sha512-e3k2Vd606efd1ZYy2NQKkT4C/pn31nehyLhVug6To/q8JT8FpiMrDy7zmm3KLF0L98NOQQcutaVtAPhzKhzn9w==

"@prisma/engines@3.14.0-36.2b0c12756921c891fec4f68d9444e18c7d5d4a6a":
version "3.14.0-36.2b0c12756921c891fec4f68d9444e18c7d5d4a6a"
resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-3.14.0-36.2b0c12756921c891fec4f68d9444e18c7d5d4a6a.tgz#7fa11bc26a51d450185c816cc0ab8cac673fb4bf"
integrity sha512-LwZvI3FY6f43xFjQNRuE10JM5R8vJzFTSmbV9X0Wuhv9kscLkjRlZt0BEoiHmO+2HA3B3xxbMfB5du7ZoSFXGg==
"@prisma/engines@3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e":
version "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e"
resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e.tgz#f691893df506b93e3cb1ccc15ec6e5ac64e8e570"
integrity sha512-NHlojO1DFTsSi3FtEleL9QWXeSF/UjhCW0fgpi7bumnNZ4wj/eQ+BJJ5n2pgoOliTOGv9nX2qXvmHap7rJMNmg==

"@reach/observe-rect@^1.1.0":
version "1.2.0"
Expand Down Expand Up @@ -12377,12 +12377,12 @@ prism-react-renderer@^1.3.3:
resolved "https://registry.yarnpkg.com/prism-react-renderer/-/prism-react-renderer-1.3.3.tgz#9b5a4211a6756eee3c96fee9a05733abc0b0805c"
integrity sha512-Viur/7tBTCH2HmYzwCHmt2rEFn+rdIWNIINXyg0StiISbDiIhHKhrFuEK8eMkKgvsIYSjgGqy/hNyucHp6FpoQ==

prisma@^3.14.0:
version "3.14.0"
resolved "https://registry.yarnpkg.com/prisma/-/prisma-3.14.0.tgz#dd67ece37d7b5373e9fd9588971de0024b49be81"
integrity sha512-l9MOgNCn/paDE+i1K2fp9NZ+Du4trzPTJsGkaQHVBufTGqzoYHuNk8JfzXuIn0Gte6/ZjyKj652Jq/Lc1tp2yw==
prisma@^3.15.2:
version "3.15.2"
resolved "https://registry.yarnpkg.com/prisma/-/prisma-3.15.2.tgz#4ebe32fb284da3ac60c49fbc16c75e56ecf32067"
integrity sha512-nMNSMZvtwrvoEQ/mui8L/aiCLZRCj5t6L3yujKpcDhIPk7garp8tL4nMx2+oYsN0FWBacevJhazfXAbV1kfBzA==
dependencies:
"@prisma/engines" "3.14.0-36.2b0c12756921c891fec4f68d9444e18c7d5d4a6a"
"@prisma/engines" "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e"

prismjs@^1.28.0:
version "1.28.0"
Expand Down

5 comments on commit 18c5ea5

@vercel
Copy link

@vercel vercel bot commented on 18c5ea5 Jun 20, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

docs – ./apps/docs

docs.typebot.io
docs-git-main-typebot-io.vercel.app
docs-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 18c5ea5 Jun 20, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

viewer-v2-alpha – ./apps/viewer

ar.nigerias.io
apr.nigerias.io
bot.aws.bj
bt.id8rs.com
am.nigerias.io
an.nigerias.io
aso.nigerias.io
apo.nigerias.io
vhpage.cr8.ai
sat.cr8.ai
chat.sureb4.com
clo.closeer.work
bot.upfunnel.art
bot.piccinato.co
sakuranembro.it
games.klujo.com
faqs.nigerias.io
eventhub.com.au
stan.vselise.com
feedback.ofx.one
voicehelp.cr8.ai
zap.techadviser.in
app.chatforms.net
this-is-a-test.com
bot.eventhub.com.au
goalsettingbot.com
bot.ansuraniphone.my
forms.webisharp.com
typebot.stillio.com
bot.cotemeuplano.com
chat.hayurihijab.com
get.freebotoffer.xyz
bot.incusservices.com
chat.missarkansas.org
cdd.searchcube.com.sg
form.searchcube.com.sg
bot.meuesocial.com.br
c23111azqw.nigerias.io
apply.ansuraniphone.my
gcase.barrettamario.it
info.clickasuransi.com
kodawariab736.skeep.it
view.onlinebotdemo.xyz
form.sergiolimajr.com.br
83242573.actualizar.xyz
mainmenu.diddancing.com
type.opaulovieira.com.br
serviziaziendali.online
hunterbot.saleshunter.ai
aibot.angrybranding.co.uk
boyfriend-breakup.riku.ai
designguide.techyscouts.com
type.dericsoncalari.com.br
piazzatorre.barrettamario.it
bot.comercializadoraomicron.com
onboarding.libertydreamcare.ie
type.talitasouzamarques.com.br
agendamento.sergiolimajr.com.br
personal-trainer.barrettamario.it
bookings.littlepartymonkeys.com
preagendamento.sergiolimajr.com.br
viewer-v2-alpha-typebot-io.vercel.app
studiotecnicoimmobiliaremerelli.it
viewer-v2-alpha-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 18c5ea5 Jun 20, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-typebot-io.vercel.app
app.typebot.io
builder-v2-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 18c5ea5 Jun 20, 2022

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on 18c5ea5 Jun 20, 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.