🧐 Better inspectUser script
This commit is contained in:
@ -32,11 +32,14 @@ const inspectTypebot = async () => {
|
|||||||
publicId: true,
|
publicId: true,
|
||||||
customDomain: true,
|
customDomain: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
|
isArchived: true,
|
||||||
workspace: {
|
workspace: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
name: true,
|
name: true,
|
||||||
plan: true,
|
plan: true,
|
||||||
|
isPastDue: true,
|
||||||
|
isSuspended: true,
|
||||||
members: {
|
members: {
|
||||||
select: {
|
select: {
|
||||||
role: true,
|
role: true,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { PrismaClient } from '@typebot.io/prisma'
|
import { PrismaClient } from '@typebot.io/prisma'
|
||||||
import { promptAndSetEnvironment } from './utils'
|
import { promptAndSetEnvironment } from './utils'
|
||||||
import { isCancel, text } from '@clack/prompts'
|
import { isCancel, text, confirm } from '@clack/prompts'
|
||||||
|
|
||||||
const inspectUser = async () => {
|
const inspectUser = async () => {
|
||||||
await promptAndSetEnvironment('production')
|
await promptAndSetEnvironment('production')
|
||||||
@ -33,7 +33,17 @@ const inspectUser = async () => {
|
|||||||
name: true,
|
name: true,
|
||||||
plan: true,
|
plan: true,
|
||||||
isVerified: true,
|
isVerified: true,
|
||||||
|
stripeId: true,
|
||||||
|
isSuspended: true,
|
||||||
members: {
|
members: {
|
||||||
|
select: {
|
||||||
|
role: true,
|
||||||
|
user: {
|
||||||
|
select: {
|
||||||
|
email: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
where: {
|
where: {
|
||||||
user: { email: { not: email } },
|
user: { email: { not: email } },
|
||||||
},
|
},
|
||||||
@ -66,6 +76,32 @@ const inspectUser = async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
console.log(JSON.stringify(user, null, 2))
|
console.log(JSON.stringify(user, null, 2))
|
||||||
|
|
||||||
|
const computeResults = await confirm({
|
||||||
|
message: 'Compute collected results?',
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!computeResults || isCancel(computeResults)) process.exit()
|
||||||
|
|
||||||
|
console.log('Computing collected results...')
|
||||||
|
|
||||||
|
for (const workspace of user?.workspaces ?? []) {
|
||||||
|
for (const typebot of workspace.workspace.typebots) {
|
||||||
|
const resultsCount = await prisma.result.count({
|
||||||
|
where: {
|
||||||
|
typebotId: typebot.id,
|
||||||
|
isArchived: false,
|
||||||
|
hasStarted: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
if (resultsCount === 0) continue
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`Typebot "${typebot.name}" (${typebot.id}) has ${resultsCount} collected results`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inspectUser()
|
inspectUser()
|
||||||
|
Reference in New Issue
Block a user