diff --git a/frappe/desk/doctype/system_health_queue/__init__.py b/frappe/desk/doctype/system_health_queue/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frappe/desk/doctype/system_health_queue/system_health_queue.json b/frappe/desk/doctype/system_health_queue/system_health_queue.json new file mode 100644 index 0000000000..e70bf98521 --- /dev/null +++ b/frappe/desk/doctype/system_health_queue/system_health_queue.json @@ -0,0 +1,39 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2024-04-18 17:38:33.006527", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "queue", + "pending_jobs" + ], + "fields": [ + { + "fieldname": "queue", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Queue" + }, + { + "fieldname": "pending_jobs", + "fieldtype": "Int", + "in_list_view": 1, + "label": "Pending Jobs" + } + ], + "index_web_pages_for_search": 1, + "is_virtual": 1, + "istable": 1, + "links": [], + "modified": "2024-04-18 17:38:59.244386", + "modified_by": "Administrator", + "module": "Desk", + "name": "System Health Queue", + "owner": "Administrator", + "permissions": [], + "sort_field": "creation", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/frappe/desk/doctype/system_health_queue/system_health_queue.py b/frappe/desk/doctype/system_health_queue/system_health_queue.py new file mode 100644 index 0000000000..9eed8aec40 --- /dev/null +++ b/frappe/desk/doctype/system_health_queue/system_health_queue.py @@ -0,0 +1,46 @@ +# Copyright (c) 2024, Frappe Technologies and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + + +class SystemHealthQueue(Document): + # begin: auto-generated types + # This code is auto-generated. Do not modify anything in this block. + + from typing import TYPE_CHECKING + + if TYPE_CHECKING: + from frappe.types import DF + + parent: DF.Data + parentfield: DF.Data + parenttype: DF.Data + pending_jobs: DF.Int + queue: DF.Data | None + # end: auto-generated types + + def db_insert(self, *args, **kwargs): + raise NotImplementedError + + def load_from_db(self): + raise NotImplementedError + + def db_update(self): + raise NotImplementedError + + def delete(self): + raise NotImplementedError + + @staticmethod + def get_list(filters=None, page_length=20, **kwargs): + pass + + @staticmethod + def get_count(filters=None, **kwargs): + pass + + @staticmethod + def get_stats(**kwargs): + pass diff --git a/frappe/desk/doctype/system_health_report/system_health_report.json b/frappe/desk/doctype/system_health_report/system_health_report.json index 31394c4580..9bdb65d4e6 100644 --- a/frappe/desk/doctype/system_health_report/system_health_report.json +++ b/frappe/desk/doctype/system_health_report/system_health_report.json @@ -6,7 +6,11 @@ "field_order": [ "background_jobs_section", "scheduler_status", + "column_break_klex", "total_background_workers", + "section_break_djoz", + "queue_status", + "column_break_wjoz", "background_workers" ], "fields": [ @@ -30,6 +34,24 @@ "fieldname": "scheduler_status", "fieldtype": "Data", "label": "Scheduler Status" + }, + { + "fieldname": "queue_status", + "fieldtype": "Table", + "label": "Queue Status", + "options": "System Health Queue" + }, + { + "fieldname": "column_break_klex", + "fieldtype": "Column Break" + }, + { + "fieldname": "section_break_djoz", + "fieldtype": "Section Break" + }, + { + "fieldname": "column_break_wjoz", + "fieldtype": "Column Break" } ], "hide_toolbar": 1, @@ -37,7 +59,7 @@ "is_virtual": 1, "issingle": 1, "links": [], - "modified": "2024-04-18 17:32:01.054494", + "modified": "2024-04-18 17:44:06.856892", "modified_by": "Administrator", "module": "Desk", "name": "System Health Report", diff --git a/frappe/desk/doctype/system_health_report/system_health_report.py b/frappe/desk/doctype/system_health_report/system_health_report.py index ebf6544e6f..48eba3a401 100644 --- a/frappe/desk/doctype/system_health_report/system_health_report.py +++ b/frappe/desk/doctype/system_health_report/system_health_report.py @@ -24,6 +24,7 @@ from collections import defaultdict import frappe from frappe.model.document import Document +from frappe.utils.background_jobs import get_queue, get_queue_list from frappe.utils.scheduler import get_scheduler_status @@ -34,10 +35,12 @@ class SystemHealthReport(Document): from typing import TYPE_CHECKING if TYPE_CHECKING: + from frappe.desk.doctype.system_health_queue.system_health_queue import SystemHealthQueue from frappe.desk.doctype.system_health_workers.system_health_workers import SystemHealthWorkers from frappe.types import DF background_workers: DF.Table[SystemHealthWorkers] + queue_status: DF.Table[SystemHealthQueue] scheduler_status: DF.Data | None total_background_workers: DF.Int # end: auto-generated types @@ -69,6 +72,16 @@ class SystemHealthReport(Document): }, ) + for queue in get_queue_list(): + q = get_queue(queue) + self.append( + "queue_status", + { + "queue": queue, + "pending_jobs": q.count, + }, + ) + def db_update(self): raise NotImplementedError