mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-29 09:54:47 +00:00
refactor(supplier_scorecard): replace sql with orm (#55169)
This commit is contained in:
@@ -140,28 +140,20 @@ class SupplierScorecard(Document):
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_timeline_data(doctype: str, name: str):
|
def get_timeline_data(doctype: str, name: str):
|
||||||
# Get a list of all the associated scorecards
|
# Get a list of all the associated scorecards
|
||||||
scs = frappe.get_doc(doctype, name)
|
|
||||||
out = {}
|
out = {}
|
||||||
timeline_data = {}
|
timeline_data = {}
|
||||||
scorecards = frappe.db.sql(
|
|
||||||
"""
|
scorecards = frappe.get_all(
|
||||||
SELECT
|
"Supplier Scorecard Period",
|
||||||
sc.name
|
fields=["name", "start_date", "end_date", "total_score"],
|
||||||
FROM
|
filters={"scorecard": name, "docstatus": 1},
|
||||||
`tabSupplier Scorecard Period` sc
|
order_by="end_date desc",
|
||||||
WHERE
|
|
||||||
sc.scorecard = %(scs)s
|
|
||||||
AND sc.docstatus = 1""",
|
|
||||||
{"scs": scs.name},
|
|
||||||
as_dict=1,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
for sc in scorecards:
|
for sc in scorecards:
|
||||||
start_date, end_date, total_score = frappe.db.get_value(
|
for single_date in daterange(sc.start_date, sc.end_date):
|
||||||
"Supplier Scorecard Period", sc.name, ["start_date", "end_date", "total_score"]
|
timeline_data[time.mktime(single_date.timetuple())] = sc.total_score
|
||||||
)
|
|
||||||
for single_date in daterange(start_date, end_date):
|
|
||||||
timeline_data[time.mktime(single_date.timetuple())] = total_score
|
|
||||||
|
|
||||||
out["timeline_data"] = timeline_data
|
out["timeline_data"] = timeline_data
|
||||||
return out
|
return out
|
||||||
|
|||||||
Reference in New Issue
Block a user