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

Bulk delete #1030

Closed
wants to merge 1 commit into from
Closed

Bulk delete #1030

wants to merge 1 commit into from

Conversation

@Amedeo91
Copy link

@Amedeo91 Amedeo91 commented Jun 20, 2017

Bulk delete fix +Adding callback on the bulk delete flow for customization purpose

Issue #1028
Issue #1010 --> to support the possibility to perform a bulk delete with a multi key unique id (Note: only for not soft delete, as per soft delete is possible to achieve it with customisation in the datalayer)

@Amedeo91 Amedeo91 force-pushed the Amedeo91:Bulk_delete branch 5 times, most recently from d4b10e3 to 6da4a44 Jun 20, 2017
@nicolaiarocci
Copy link
Member

@nicolaiarocci nicolaiarocci commented Jun 21, 2017

Are you basically attempting to make DELETE a batch operation, whereas so far it's been an individual (document endpoint) or complete (resource endpoint) operation?

getattr(app, "on_delete_resource")(resource)
getattr(app, "on_delete_resource_%s" % resource)()
default_request = ParsedRequest()
if config.DOMAIN[resource]['soft_delete']:

This comment has been minimized.

@nicolaiarocci

nicolaiarocci Jun 21, 2017
Member

could use resource_def here?

This comment has been minimized.

if config.DOMAIN[resource]['soft_delete']:
# get_document should always fetch soft deleted documents from the db
# callers must handle soft deleted documents
default_request.show_deleted = True

This comment has been minimized.

@nicolaiarocci

nicolaiarocci Jun 21, 2017
Member

Why returning already deleted documents to the callback? Busines logic should have been applied on original deletion, right?

This comment has been minimized.

@Amedeo91

Amedeo91 Jun 21, 2017
Author

Well, in this case, I would like to offer to the client possibility to customize what he wants to delete. A possible use case can be that in the collection there are documents which should not be deleted by the client (i.e. included service for a trip, like included car or included checked baggage).

Therefore, it might be possible by modifying the query (in the case on hard delete) or modify the originals (removing what we do not what to delete) in the callback.

@Amedeo91
Copy link
Author

@Amedeo91 Amedeo91 commented Jun 21, 2017

Hi Nicola, basically, I just want to enforce that we should delete what we fetch. Therefore, if in the URL we are allowing to specify some parameters (i.e. person with for follow url users/<regex("[a-f0-9]{24}"):person>/invoices --> lookup = {"person" : value}), we should use the some parameters to do the delete.

@@ -38,7 +38,7 @@ def deleteitem(resource, **lookup):


def deleteitem_internal(
resource, concurrency_check=False, suppress_callbacks=False, **lookup):
resource, concurrency_check=False, suppress_callbacks=False, original=None, **lookup):

This comment has been minimized.

@nicolaiarocci

nicolaiarocci Jun 22, 2017
Member

missing docstring update here

@@ -150,7 +149,8 @@ def deleteitem_internal(
app.media.delete(original[field], resource)

id = original[resource_def['id_field']]
app.data.remove(resource, {resource_def['id_field']: id})
# We should delete what we fetch. Since the id_field might not be unique, let's use the lookup

This comment has been minimized.

@nicolaiarocci

nicolaiarocci Jun 22, 2017
Member

this comment can be deleted

if resource_def['soft_delete']:
# get_document should always fetch soft deleted documents from the db
# callers must handle soft deleted documents
default_request.show_deleted = True

This comment has been minimized.

@nicolaiarocci

nicolaiarocci Jun 22, 2017
Member

this behavior should probably be explained in the Soft Delete section of the docs. Explain that the new callback will include soft-deleted documents when soft delete is active.

@@ -21,6 +21,27 @@ def test_unknown_resource(self):
_, status = self.delete(url)
self.assert404(status)

def test_bulk_delete_id_field(self):

This comment has been minimized.

@nicolaiarocci

nicolaiarocci Jun 22, 2017
Member

the new DELETE behavior should be explained in the docs, probably in the Sub Resources of the features page.

@Amedeo91 Amedeo91 force-pushed the Amedeo91:Bulk_delete branch 2 times, most recently from f7b2cb4 to 1753b1d Jun 22, 2017
@Amedeo91
Copy link
Author

@Amedeo91 Amedeo91 commented Jun 22, 2017

Hi Nicola,

thanks for your review! :) I did the update you suggested to me.

Regards,
Amedeo

@nicolaiarocci
Copy link
Member

@nicolaiarocci nicolaiarocci commented Jun 25, 2017

Could you please squash all commits into one?

Amedeo91
@Amedeo91 Amedeo91 force-pushed the Amedeo91:Bulk_delete branch from 1753b1d to c94026c Jun 26, 2017
@Amedeo91
Copy link
Author

@Amedeo91 Amedeo91 commented Jun 26, 2017

Ciao Nicola,

commit uniti! :)

Ciao,
Amedeo

@Amedeo91
Copy link
Author

@Amedeo91 Amedeo91 commented Jul 10, 2017

Hi @nicolaiarocci, is there anything else I should do for this PR?

Regards,
Amedeo

nicolaiarocci added a commit that referenced this pull request Jul 15, 2017
@nicolaiarocci
Copy link
Member

@nicolaiarocci nicolaiarocci commented Jul 15, 2017

Merged after a rebase and some fixes, see 63d87fc.

Thanks!

Amedeo91 pushed a commit to Amedeo91/eve that referenced this pull request Aug 11, 2017
Amedeo91 pushed a commit to Amedeo91/eve that referenced this pull request Aug 11, 2017
Amedeo91 pushed a commit to Amedeo91/eve that referenced this pull request Aug 11, 2017
lexhung added a commit to lexhung/eve that referenced this pull request Nov 1, 2017
* 'master' of https://github.com/pyeve/eve: (374 commits)
  Changelog for pyeve#1070
  use OrderedDict from backport_collections
  Minor changelog fixes for pyeve#1048
  Support Decimal type MongoDB
  Changelog: add reference to proper PR
  Changelog update for pyeve#1042
  Fix a serialization bug that randomly skips fields if "x_of" is encountered
  Amedeo Bussi
  Changelog for pyeve#1030
  pep/flake, and remove duplicate test
  documentation improvements and fixes
  Bulk delete
  MONGO_DBNAME can be now used along with MONGO_URI
  Vasilis Lolis
  typo
  Amedeo91
  Changelog for pyeve#1031
  Bulk Embedded document resolution
  Delete unnecessary code
  Fix insidious bug in tests.TestPost class
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants