From 1894709aa3bd600a11c8a80dd2e77a5b906a91c0 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 11 Jun 2013 17:08:16 +0530 Subject: [PATCH 1/2] [patch] [cleanup] remove unused doctypes --- patches/patch_list.py | 1 + 1 file changed, 1 insertion(+) diff --git a/patches/patch_list.py b/patches/patch_list.py index 69e3fbb7c7..03f7e7327e 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -242,4 +242,5 @@ patch_list = [ "patches.june_2013.p02_update_project_completed", "execute:webnotes.delete_doc('DocType', 'System Console')", "patches.june_2013.p04_fix_event_for_lead_oppty_project", + "patches.june_2013.p05_remove_unused_doctypes" ] \ No newline at end of file From a642d59cfd8e0c6ce12df78d774196efc5c6476b Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 11 Jun 2013 17:32:48 +0530 Subject: [PATCH 2/2] [patch] [cleanup] drop unused tables --- .../june_2013/p05_remove_unused_doctypes.py | 87 +++++++++++++++++++ patches/june_2013/p06_drop_unused_tables.py | 78 +++++++++++++++++ patches/patch_list.py | 3 +- startup/startup.py | 6 -- 4 files changed, 167 insertions(+), 7 deletions(-) create mode 100644 patches/june_2013/p05_remove_unused_doctypes.py create mode 100644 patches/june_2013/p06_drop_unused_tables.py diff --git a/patches/june_2013/p05_remove_unused_doctypes.py b/patches/june_2013/p05_remove_unused_doctypes.py new file mode 100644 index 0000000000..62cf880729 --- /dev/null +++ b/patches/june_2013/p05_remove_unused_doctypes.py @@ -0,0 +1,87 @@ +import webnotes + +def execute(): + doctypes = [ + "Announcement", + "Authorization Rules", + "Blog Subscriber", + "Books", + "Call Log", + "Call Log Details", + "Campaign Expense", + "Communication Log", + "Compaint Note", + "Company Control", + "Competitor", + "Complaint Detail", + "Desktop Item", + "DocType Label", + "Employee Training", + "Featured Item", + "GL Control", + "GL Mapper", + "GL Mapper Detail", + "Holiday Block List", + "Holiday Block List Allow", + "Holiday Block List Date", + "Home Control", + "Home Settings", + "Item Parameter", + "Item Parameter Value", + "Lead Email CC Detail", + "Manage Account", + "Market Segment", + "Multi Ledger Report Detail", + "Naming Series Options", + "Navigation Control", + "Online Contact", + "Order Reconciliation", + "Order Reconciliation Detail", + "Other Income Detail", + "Partner Target Detail", + "Permission Control", + "Permission Rules", + "Print Style", + "Product Catalogue Control", + "Product Group", + "Product Settings", + "Products Settings", + "Profile Control", + "Project Activity", + "Project Activity Update", + "Project Control", + "Project Cost Breakup", + "Related Page", + "RV Detail", + "Sales Browser Control", + "Sandbox", + "Search Criteria", + "Series Detail", + "Shipping Address", + "SMS Receiver", + "State", + "TC Detail", + "Territory Target Detail", + "Timesheet", + "Timesheet Detail", + "Top Bar Settings", + "Training Session", + "Training Session Details", + "Transfer Ownership", + "Trash Control", + "Trend Analyzer Control", + "Update Delivery Date", + "User Setting-Profile", + "User Setting-Role Permission", + "User Setting-Role User", + "User Settings", + "Valuation Control", + "Website Product Category", + "Workflow Action Detail", + "Workflow Engine", + "Workflow Rule", + "Workflow Rule Detail" + ] + + for d in doctypes: + webnotes.delete_doc("DocType", d) \ No newline at end of file diff --git a/patches/june_2013/p06_drop_unused_tables.py b/patches/june_2013/p06_drop_unused_tables.py new file mode 100644 index 0000000000..baad451c05 --- /dev/null +++ b/patches/june_2013/p06_drop_unused_tables.py @@ -0,0 +1,78 @@ +import webnotes + +def execute(): + tables = [ + "About Us Team", + "Account Balance", + "Announcement", + "Answer", + "Blog Subscriber", + "Books", + "Call Log", + "Call Log Details", + "Campaign Expense", + "Communication Log", + "Compaint Note", + "Competitor", + "Complaint Detail", + "Desktop Item", + "DocType Label", + "Employee Training", + "Featured Item", + "GL Mapper", + "GL Mapper Detail", + "Holiday Block List", + "Holiday Block List Allow", + "Holiday Block List Date", + "Item Parameter", + "Item Parameter Value", + "Landed Cost Master", + "Landed Cost Master Detail", + "Lead Email CC Detail", + "Lease Agreement", + "Lease Installment", + "Market Segment", + "Multi Ledger Report Detail", + "Naming Series Options", + "Online Contact", + "Order Reconciliation Detail", + "Other Income Detail", + "Partner Target Detail", + "Period", + "Print Style", + "Product", + "Product Group", + "Project Activity", + "Project Activity Update", + "Project Cost Breakup", + "Question", + "RV Detail", + "Related Page", + "SMS Receiver", + "Sales and Purchase Return Item", + "Sandbox", + "Series Detail", + "Service Order Detail", + "Service Quotation Detail", + "Shipping Address", + "State", + "TC Detail", + "Territory Target Detail", + "Timesheet", + "Timesheet Detail", + "Training Session", + "Training Session Details", + "User Setting-Profile", + "User Setting-Role Permission", + "User Setting-Role User", + "Website Product Category", + "Workflow Action Detail", + "Workflow Rule", + "Workflow Rule Detail", + ] + + webnotes.conn.sql("commit") + all_tables = webnotes.conn.sql_list("show tables") + for t in tables: + if ("tab" + t) in all_tables: + webnotes.conn.sql("drop table `tab%s`" % t) \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 03f7e7327e..a1012baa09 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -242,5 +242,6 @@ patch_list = [ "patches.june_2013.p02_update_project_completed", "execute:webnotes.delete_doc('DocType', 'System Console')", "patches.june_2013.p04_fix_event_for_lead_oppty_project", - "patches.june_2013.p05_remove_unused_doctypes" + "patches.june_2013.p05_remove_unused_doctypes", + "patches.june_2013.p06_drop_unused_tables" ] \ No newline at end of file diff --git a/startup/startup.py b/startup/startup.py index 89c0336d17..2ca2643cb7 100644 --- a/startup/startup.py +++ b/startup/startup.py @@ -62,11 +62,6 @@ def get_todays_events(): def get_open_leads(): return webnotes.conn.sql("""select count(*) from tabLead where status='Open'""")[0][0] - -def get_unanswered_questions(): - return len(filter(lambda d: d[0]==0, - webnotes.conn.sql("""select (select count(*) from tabAnswer - where tabAnswer.question = tabQuestion.name) as answers from tabQuestion"""))) @webnotes.whitelist() def get_global_status_messages(arg=None): @@ -76,6 +71,5 @@ def get_global_status_messages(arg=None): 'things_todo': get_things_todo(), 'todays_events': get_todays_events(), 'open_tasks': get_open_tasks(), - 'unanswered_questions': get_unanswered_questions(), 'open_leads': get_open_leads() }