From ace1b2dcbde1704b804d0cd2ad2f9888012681c1 Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Wed, 20 Nov 2024 13:39:21 +0530 Subject: [PATCH] fix: compatibility with v14 --- .../insights_table_v3/insights_table_v3.py | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/insights/insights/doctype/insights_table_v3/insights_table_v3.py b/insights/insights/doctype/insights_table_v3/insights_table_v3.py index 3d949808..a199213e 100644 --- a/insights/insights/doctype/insights_table_v3/insights_table_v3.py +++ b/insights/insights/doctype/insights_table_v3/insights_table_v3.py @@ -5,7 +5,7 @@ from hashlib import md5 import frappe -from frappe.model.document import Document, bulk_insert +from frappe.model.document import Document from insights.insights.doctype.insights_data_source_v3.data_warehouse import Warehouse from insights.utils import InsightsDataSourcev3 @@ -32,16 +32,36 @@ def autoname(self): @staticmethod def bulk_create(data_source: str, tables: list[str]): - table_docs = [] + tables = [] for table in tables: - doc = frappe.new_doc("Insights Table v3") - doc.name = get_table_name(data_source, table) - doc.data_source = data_source - doc.table = table - doc.label = table - table_docs.append(doc) - - bulk_insert("Insights Table v3", table_docs, ignore_duplicates=True) + tables.append( + [ + get_table_name(data_source, table), + data_source, + table, + table, + frappe.utils.now(), + frappe.utils.now(), + frappe.session.user, + frappe.session.user, + ] + ) + + frappe.db.bulk_insert( + "Insights Table v3", + [ + "name", + "data_source", + "table", + "label", + "creation", + "modified", + "modified_by", + "owner", + ], + tables, + ignore_duplicates=True, + ) @staticmethod def get_ibis_table(data_source, table_name, use_live_connection=False):