chore: rename btree and remove debugging statements

This commit is contained in:
ruthra kumar 2023-09-27 14:44:48 +05:30
parent f6831fba13
commit 6492019383
8 changed files with 26 additions and 32 deletions

View File

@ -41,7 +41,6 @@ frappe.ui.form.on("Bisect Accounting Statements", {
datapoints[epoch_in_seconds] = 0.0;
}
}
console.log(datapoints);
new frappe.Chart(".bisect_heatmap_location", {
type: "heatmap",
@ -61,7 +60,6 @@ frappe.ui.form.on("Bisect Accounting Statements", {
method: 'bisect_left',
callback: (r) => {
frm.trigger("render_heatmap");
console.log(r);
}
});
},
@ -71,7 +69,6 @@ frappe.ui.form.on("Bisect Accounting Statements", {
method: 'bisect_right',
callback: (r) => {
frm.trigger("render_heatmap");
console.log(r);
}
});
},
@ -81,7 +78,6 @@ frappe.ui.form.on("Bisect Accounting Statements", {
method: 'move_up',
callback: (r) => {
frm.trigger("render_heatmap");
console.log(r);
}
});
},
@ -91,7 +87,6 @@ frappe.ui.form.on("Bisect Accounting Statements", {
method: 'build_tree',
callback: (r) => {
frm.trigger("render_heatmap");
console.log(r);
}
});
},

View File

@ -59,7 +59,7 @@
"fieldname": "current_node",
"fieldtype": "Link",
"label": "Current Node",
"options": "Nodes"
"options": "Bisect Nodes"
},
{
"fieldname": "section_break_hmsy",
@ -128,8 +128,7 @@
},
{
"fieldname": "section_break_8ph9",
"fieldtype": "Section Break",
"hidden": 1
"fieldtype": "Section Break"
},
{
"fieldname": "bisect_heatmap",
@ -141,7 +140,7 @@
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2023-09-27 14:32:09.962067",
"modified": "2023-09-27 15:05:44.285832",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Bisect Accounting Statements",

View File

@ -27,7 +27,7 @@ class BisectAccountingStatements(Document):
def bfs(self, from_date: datetime, to_date: datetime):
# Make Root node
node = frappe.new_doc("Nodes")
node = frappe.new_doc("Bisect Nodes")
node.root = None
node.period_from_date = from_date
node.period_to_date = to_date
@ -42,7 +42,7 @@ class BisectAccountingStatements(Document):
else:
cur_floor = floor(delta.days / 2)
next_to_date = cur_node.period_from_date + relativedelta(days=+cur_floor)
left_node = frappe.new_doc("Nodes")
left_node = frappe.new_doc("Bisect Nodes")
left_node.period_from_date = cur_node.period_from_date
left_node.period_to_date = next_to_date
left_node.root = cur_node.name
@ -51,7 +51,7 @@ class BisectAccountingStatements(Document):
period_queue.append(left_node)
next_from_date = cur_node.period_from_date + relativedelta(days=+(cur_floor + 1))
right_node = frappe.new_doc("Nodes")
right_node = frappe.new_doc("Bisect Nodes")
right_node.period_from_date = next_from_date
right_node.period_to_date = cur_node.period_to_date
right_node.root = cur_node.name
@ -63,7 +63,7 @@ class BisectAccountingStatements(Document):
def dfs(self, from_date: datetime, to_date: datetime):
# Make Root node
node = frappe.new_doc("Nodes")
node = frappe.new_doc("Bisect Nodes")
node.root = None
node.period_from_date = from_date
node.period_to_date = to_date
@ -78,7 +78,7 @@ class BisectAccountingStatements(Document):
else:
cur_floor = floor(delta.days / 2)
next_to_date = cur_node.period_from_date + relativedelta(days=+cur_floor)
left_node = frappe.new_doc("Nodes")
left_node = frappe.new_doc("Bisect Nodes")
left_node.period_from_date = cur_node.period_from_date
left_node.period_to_date = next_to_date
left_node.root = cur_node.name
@ -87,7 +87,7 @@ class BisectAccountingStatements(Document):
period_stack.append(left_node)
next_from_date = cur_node.period_from_date + relativedelta(days=+(cur_floor + 1))
right_node = frappe.new_doc("Nodes")
right_node = frappe.new_doc("Bisect Nodes")
right_node.period_from_date = next_from_date
right_node.period_to_date = cur_node.period_to_date
right_node.root = cur_node.name
@ -99,7 +99,7 @@ class BisectAccountingStatements(Document):
@frappe.whitelist()
def build_tree(self):
frappe.db.delete("Nodes")
frappe.db.delete("Bisect Nodes")
# Convert str to datetime format
dt_format = guess_date_format(self.from_date)
@ -113,7 +113,7 @@ class BisectAccountingStatements(Document):
self.dfs(from_date, to_date)
# set root as current node
root = frappe.db.get_all("Nodes", filters={"root": ["is", "not set"]})[0]
root = frappe.db.get_all("Bisect Nodes", filters={"root": ["is", "not set"]})[0]
frappe.db.set_single_value("Bisect Accounting Statements", "current_node", root.name)
def get_report_summary(self):
@ -133,9 +133,9 @@ class BisectAccountingStatements(Document):
@frappe.whitelist()
def bisect_left(self):
if self.current_node is not None:
cur_node = frappe.get_doc("Nodes", self.current_node)
cur_node = frappe.get_doc("Bisect Nodes", self.current_node)
if cur_node.left_child is not None:
lft_node = frappe.get_doc("Nodes", cur_node.left_child)
lft_node = frappe.get_doc("Bisect Nodes", cur_node.left_child)
self.current_node = cur_node.left_child
self.current_from_date = lft_node.period_from_date
self.current_to_date = lft_node.period_to_date
@ -147,9 +147,9 @@ class BisectAccountingStatements(Document):
@frappe.whitelist()
def bisect_right(self):
if self.current_node is not None:
cur_node = frappe.get_doc("Nodes", self.current_node)
cur_node = frappe.get_doc("Bisect Nodes", self.current_node)
if cur_node.right_child is not None:
rgt_node = frappe.get_doc("Nodes", cur_node.right_child)
rgt_node = frappe.get_doc("Bisect Nodes", cur_node.right_child)
self.current_node = cur_node.right_child
self.current_from_date = rgt_node.period_from_date
self.current_to_date = rgt_node.period_to_date
@ -161,9 +161,9 @@ class BisectAccountingStatements(Document):
@frappe.whitelist()
def move_up(self):
if self.current_node is not None:
cur_node = frappe.get_doc("Nodes", self.current_node)
cur_node = frappe.get_doc("Bisect Nodes", self.current_node)
if cur_node.root is not None:
root = frappe.get_doc("Nodes", cur_node.root)
root = frappe.get_doc("Bisect Nodes", cur_node.root)
self.current_node = cur_node.root
self.current_from_date = root.period_from_date
self.current_to_date = root.period_to_date

View File

@ -1,7 +1,7 @@
// Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
// frappe.ui.form.on("Nodes", {
// frappe.ui.form.on("Bisect Nodes", {
// refresh(frm) {
// },

View File

@ -1,7 +1,7 @@
{
"actions": [],
"autoname": "autoincrement",
"creation": "2023-09-25 22:01:33.961832",
"creation": "2023-09-27 14:56:38.112462",
"default_view": "List",
"doctype": "DocType",
"editable_grid": 1,
@ -21,19 +21,19 @@
"fieldname": "root",
"fieldtype": "Link",
"label": "Root",
"options": "Nodes"
"options": "Bisect Nodes"
},
{
"fieldname": "left_child",
"fieldtype": "Link",
"label": "Left Child",
"options": "Nodes"
"options": "Bisect Nodes"
},
{
"fieldname": "right_child",
"fieldtype": "Link",
"label": "Right Child",
"options": "Nodes"
"options": "Bisect Nodes"
},
{
"fieldname": "period_from_date",
@ -63,10 +63,10 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-09-25 22:05:49.577861",
"modified": "2023-09-27 15:09:27.715523",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Nodes",
"name": "Bisect Nodes",
"naming_rule": "Autoincrement",
"owner": "Administrator",
"permissions": [

View File

@ -5,5 +5,5 @@
from frappe.model.document import Document
class Nodes(Document):
class BisectNodes(Document):
pass

View File

@ -5,5 +5,5 @@
from frappe.tests.utils import FrappeTestCase
class TestNodes(FrappeTestCase):
class TestBisectNodes(FrappeTestCase):
pass