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

Improvements to project deletion operation #614

Merged
merged 4 commits into from
Feb 23, 2023
Merged

Improvements to project deletion operation #614

merged 4 commits into from
Feb 23, 2023

Conversation

jaragunde
Copy link
Member

  • Better feedback on error.
  • Port to PDO.
  • Delete user assignments when deleting a project.
  • Remove unused code.

$sql = "DELETE FROM project WHERE id=".$projectVO->getId();
$result->setIsSuccessful(true);
$result->setMessage('Project deleted successfully.');
$result->setResponseCode(201);
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't it be 200 in this case as 201 is for created?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agree with Ana that this should probably return 200. We can use 201 in results where we are adding records, since a 'created' is more descriptive.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy & paste error, thanks for pointing out 🙂

}
$string .= "</errors></return>";
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I was wondering if we shouldn't have just the if (count($deleteProjects) > 1) block since we run a loop in the list of projects it should work with 1 or more.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we even delete multiple projects at once from the UI? I remember we had a discussion about this for the creation of projects and landed on leaving in code that handles multiples for the time being. Still, Ana has a good point that this block could be simplified either way. I think that means that the code I wrote for creating projects could similarly be simplified.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's the same case here, the UI cannot even delete multiple projects but the service allows it. Following the same reasoning, I left that ability in place, just in case.

It's true it can be simplified, anyway, so I'll do it. I'll submit a follow-up for the create operation.

Copy link
Member

@anarute anarute left a comment

Choose a reason for hiding this comment

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

I've just had small nit pick comments, overall it looks good to me, thank you!

Copy link
Collaborator

@dmtrek14 dmtrek14 left a comment

Choose a reason for hiding this comment

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

Other than agreeing with the couple items Ana raised, I don't have much to add. Everything looks good!

Since we had to rewrite the delete DAO operation, we did it in PDO
terms, addressing #513 too.
We add a DELETE CASCADE restriction to remove entries in the project_usr
table at the same time we delete the corresponding project.

Other restrictions to delete projects are still in place, for example,
you cannot delete a project that has assigned tasks due to other foreign
key constraints.

This being a change in the database, we bump its version too, and write
an upgrade script.
@jaragunde
Copy link
Member Author

Thanks for your reviews!

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.

3 participants