def undelete_docs(db, doc_ids): results = Results(set(), set(), set()) with IterDB(db) as iter_db: for chunk in chunked(set(doc_ids), 100): for res in send_keys_to_couch(db, keys=set(chunk)): doc_id = res["key"] if res.get("error", None) == "not_found": results.not_found.add(doc_id) elif res.get("value", {}).get("deleted", False): iter_db.save(get_deleted_doc(db, doc_id, res["value"]["rev"])) results.restored.add(doc_id) else: results.not_deleted.add(doc_id) return results, iter_db
def undelete_docs(db, doc_ids): results = Results(set(), set(), set()) with IterDB(db) as iter_db: for chunk in chunked(set(doc_ids), 100): for res in send_keys_to_couch(db, keys=set(chunk)): doc_id = res['key'] if res.get('error', None) == 'not_found': results.not_found.add(doc_id) elif res.get('value', {}).get('deleted', False): iter_db.save( get_deleted_doc(db, doc_id, res['value']['rev'])) results.restored.add(doc_id) else: results.not_deleted.add(doc_id) return results, iter_db
def undelete_docs(db, doc_ids): results = Results(set(), set(), set()) with IterDB(db) as iter_db: for chunk in chunked(set(doc_ids), 100): for res in send_keys_to_couch(db, keys=set(chunk)): doc_id = res['key'] if res.get('error', None) == 'not_found': results.not_found.add(doc_id) elif res.get('value', {}).get('deleted', False): iter_db.save( get_deleted_doc(db, doc_id, res['value']['rev']) ) results.restored.add(doc_id) else: results.not_deleted.add(doc_id) return results, iter_db