impact-graph icon indicating copy to clipboard operation
impact-graph copied to clipboard

endpoint for users to delete a project in draft status from DB

Open divine-comedian opened this issue 9 months ago • 2 comments

Related to https://github.com/Giveth/giveth-dapps-v2/issues/1271 - Users should be able to delete a project they own in draft status from the DB.

We will need an endpoint for the front-end to call to trigger this action in our DB

divine-comedian avatar May 01 '24 16:05 divine-comedian

@divine-comedian pls add priority

jainkrati avatar May 08 '24 12:05 jainkrati

@Reshzera Please take this issue, it's a straight forward issue and will help you to get more familiar with impact-graph. You should implement a new endpoint in projectResolver for deleting draft projects from DB, and create a ProjectStatusHistory type to add a record on that for this purpose to can keep track of this activity

Please write test cases for below scenarios ( and if there is any scenario that I forgot to mention it, please implement them

  • [x] Success scenario, project owner should can delete his/her project
  • [x] Project owner should not be able to delete a project with non-draft status, especially write test cases for active (statusId : 5)
  • [x] User should not be able to delete someone else's project
  • [x] When deleting projects delete all related stuffs to the project like project_address, project_verification_form, project_udpate if exist
  • [ ] Make sure it creates a record in ProjectStatusHistory table

PS If you had any questions from me, feel free to ask it here or DM me

mohammadranjbarz avatar Jul 30 '24 09:07 mohammadranjbarz

I've implemented the deleteDraftProject mutation. Please note that the endpoint for this mutation is now available. To call it, use the following mutation query:

mutation ($projectId: Float!) {
  deleteDraftProject(projectId: $projectId)
}

Make sure to pass the projectId as a Float in the mutation variables.

Logic Overview:

  1. User Authentication: The mutation ensures that the user attempting to delete the draft project is authenticated by retrieving the currently logged-in user.

  2. Project Existence: It checks whether the project with the provided projectId exists in the system. If the project does not exist, an error is thrown indicating that the project could not be found.

  3. Ownership Verification: The mutation verifies that the authenticated user is the owner of the project. If the user is not the owner (i.e., their user ID does not match the adminUserId of the project), an error is thrown to prevent unauthorized deletion.

  4. Draft Status Check: The mutation ensures that only projects with a status of drafted can be deleted. If the project is not in the draft status, an error is thrown indicating that only drafted projects can be deleted.

However, note that a ProjectStatusHistory record will not be created because, as I talked to @mohammadranjbarz the project will be deleted from the database, there won't be a projectId to reference for this record.

Reshzera avatar Aug 12 '24 18:08 Reshzera

@Reshzera - since you moved this to QA is there a way for the QA to test this? if so can you please share any endpoint links or resources they might need

divine-comedian avatar Aug 12 '24 21:08 divine-comedian

@divine-comedian I spoke with @mohammadranjbarz and I don't think there is an easy way to test this issue, so I'll tag the FE guys and wait they integrate this endpoint, so QA can test this in FE. In this case, is there a correct status for this issue?

Reshzera avatar Aug 13 '24 12:08 Reshzera

sure thing @Reshzera - please update here once the FE issue is approved.

divine-comedian avatar Aug 13 '24 16:08 divine-comedian