Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove deleted threads/questions #480

Closed

Conversation

josefaidt
Copy link
Contributor

@josefaidt josefaidt commented Aug 26, 2023

Issue #, if available:

closes #475

Description of changes:

Today when a thread is deleted the question remains in the database and is not able to be "solved".

This PR fixes the issue by deleting questions from the database when their associated thread is deleted.

client.on(Events.ThreadDelete, async (thread) => {
  const log = (message: string) =>
    console.log(`[client:events.ThreadDelete] ${message}`)
  log('started')
  const timeMessage = '[client:events:ThreadDelete] finished'
  console.time(timeMessage)
  log('deleting question...')
  try {
    await prisma.question.delete({
      where: {
        threadId: thread.id,
      },
      include: {
        participation: true,
        answer: true,
      },
    })
  } catch (error) {
    console.error('Unable to delete question', error)
  }
  console.timeEnd(timeMessage)
})

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@josefaidt josefaidt requested a review from a team as a code owner August 26, 2023 01:52
@josefaidt
Copy link
Contributor Author

blocked by #479

@josefaidt josefaidt added the run-ci Label to trigger action run for CI label Aug 26, 2023
@github-actions github-actions bot removed the run-ci Label to trigger action run for CI label Aug 26, 2023
@josefaidt josefaidt added the run-ci Label to trigger action run for CI label Sep 22, 2023
@github-actions github-actions bot removed the run-ci Label to trigger action run for CI label Sep 22, 2023
@josefaidt josefaidt temporarily deployed to ci September 22, 2023 00:09 — with GitHub Actions Inactive
@nadetastic nadetastic marked this pull request as draft August 28, 2024 18:50
Gupta-Raghav pushed a commit to Gupta-Raghav/discord-bot that referenced this pull request Aug 28, 2024
@nadetastic
Copy link
Member

Closing in favor of #570

@nadetastic nadetastic closed this Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow for recording and count of GH issues that are linked within Discord
2 participants