Skip to content

Bulk delete#1030

Closed
Amedeo91 wants to merge 1 commit into
pyeve:masterfrom
Amedeo91:Bulk_delete
Closed

Bulk delete#1030
Amedeo91 wants to merge 1 commit into
pyeve:masterfrom
Amedeo91:Bulk_delete

Conversation

@Amedeo91

Copy link
Copy Markdown

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 Bulk_delete branch 5 times, most recently from d4b10e3 to 6da4a44 Compare June 20, 2017 20:06
@nicolaiarocci

Copy link
Copy Markdown
Member

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?

Comment thread eve/methods/delete.py Outdated
getattr(app, "on_delete_resource")(resource)
getattr(app, "on_delete_resource_%s" % resource)()
default_request = ParsedRequest()
if config.DOMAIN[resource]['soft_delete']:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could use resource_def here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

right

Comment thread eve/methods/delete.py
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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
Copy Markdown
Author

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.

Comment thread eve/methods/delete.py

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

missing docstring update here

Comment thread eve/methods/delete.py Outdated

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this comment can be deleted

Comment thread eve/methods/delete.py
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

_, status = self.delete(url)
self.assert404(status)

def test_bulk_delete_id_field(self):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

@Amedeo91 Amedeo91 force-pushed the Bulk_delete branch 2 times, most recently from f7b2cb4 to 1753b1d Compare June 22, 2017 10:42
@Amedeo91

Copy link
Copy Markdown
Author

Hi Nicola,

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

Regards,
Amedeo

@nicolaiarocci

Copy link
Copy Markdown
Member

Could you please squash all commits into one?

@Amedeo91

Copy link
Copy Markdown
Author

Ciao Nicola,

commit uniti! :)

Ciao,
Amedeo

@Amedeo91

Copy link
Copy Markdown
Author

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

nicolaiarocci commented Jul 15, 2017

Copy link
Copy Markdown
Member

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants