Skip to content

Commit

Permalink
feat(minor): allow clearing ansible play logs
Browse files Browse the repository at this point in the history
  • Loading branch information
phot0n committed Mar 20, 2024
1 parent 0eca860 commit 05d2dc8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions press/press/doctype/ansible_play/ansible_play.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ def get_list_query(query, filters=None, **list_args):
results = query.run(as_dict=1)
return results

@staticmethod
def clear_old_logs(days=30):
playbooks = frappe.get_all(
"Ansible Play",
filters={"modified": ["<", frappe.utils.add_days(frappe.utils.now(), -days)]},
)

for playbook in playbooks:
# will help delete ansible tasks as well
frappe.delete_doc("Ansible Play", playbook, ignore_permissions=True, delete_permanently=True)

def get_doc(self, doc):
doc["tasks"] = frappe.get_all(
"Ansible Task",
Expand Down

0 comments on commit 05d2dc8

Please sign in to comment.