def clean_documents(): """Delete all the bibdocs that have been set as deleted and have not been modified since CFG_DELETED_BIBDOC_MAXLIFE days. Returns the number of bibdocs involved.""" write_message("""CLEANING OF OBSOLETED DELETED DOCUMENTS STARTED""") write_message("select id from bibdoc where status='DELETED' and NOW()>ADDTIME(modification_date, '%s 0:0:0')" % CFG_DELETED_BIBDOC_MAXLIFE, verbose=9) records = run_sql("select id from bibdoc where status='DELETED' and NOW()>ADDTIME(modification_date, '%s 0:0:0')" % CFG_DELETED_BIBDOC_MAXLIFE) for record in records: bibdoc = BibDoc(record[0]) bibdoc.expunge() write_message("DELETE FROM bibdoc WHERE id=%i" % int(record[0]), verbose=9) run_sql("DELETE FROM bibdoc WHERE id=%s", (record[0], )) write_message("""%s obsoleted deleted documents cleaned""" % len(records)) write_message("""CLEANING OF OBSOLETED DELETED DOCUMENTS FINISHED""") return len(records)
def clean_documents(): """Delete all the bibdocs that have been set as deleted and have not been modified since CFG_DELETED_BIBDOC_MAXLIFE days. Returns the number of bibdocs involved.""" write_message("""CLEANING OF OBSOLETED DELETED DOCUMENTS STARTED""") write_message("select id from bibdoc where status='DELETED' and NOW()>ADDTIME(modification_date, '%s 0:0:0')" % CFG_DELETED_BIBDOC_MAXLIFE, verbose=9) records = run_sql("select id from bibdoc where status='DELETED' and NOW()>ADDTIME(modification_date, '%s 0:0:0')", (CFG_DELETED_BIBDOC_MAXLIFE,)) for record in records: bibdoc = BibDoc(record[0]) bibdoc.expunge() write_message("DELETE FROM bibdoc WHERE id=%i" % int(record[0]), verbose=9) run_sql("DELETE FROM bibdoc WHERE id=%s", (record[0],)) write_message("""%s obsoleted deleted documents cleaned""" % len(records)) write_message("""CLEANING OF OBSOLETED DELETED DOCUMENTS FINISHED""") return len(records)