Beispiel #1
0
def delete_unneeded_fixture_data_item(self, domain, data_type_id):
    """Deletes all fixture data items and their ownership models based on their data type.

    Note that this does not bust any caches meaning that the data items could still
    be returned to the user for some time
    """
    item_ids = []
    try:
        for items in chunked(FixtureDataItem.by_data_type(domain, data_type_id), 1000):
            FixtureDataItem.delete_docs(items)
            item_ids.extend([item.get_id for item in items])
        for item_id_chunk in chunked(item_ids, 1000):
            for docs in chunked(FixtureOwnership.for_all_item_ids(item_id_chunk, domain), 1000):
                FixtureOwnership.delete_docs(docs)
    except (KeyboardInterrupt, SystemExit):
        raise
    except Exception as exc:
        # there's no base exception in couchdbkit to catch, so must use Exception
        self.retry(exc=exc)