Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 32 additions & 35 deletions changai/changai/api/v2/schema_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,45 +184,42 @@ def validate_sql_schema(sql: str, dialect: str = "mysql") -> dict:
]


def is_doctype_schema_changed(doc,last_sync):
doctype_modified = frappe.db.get_value(
"DocType",
doc,
"modified"
)
custom_field_modified = frappe.db.get_value(
"Custom Field",
{"dt": doc},
"max(modified)"
)
property_setter_modified = frappe.db.get_value(
"Property Setter",
{"doc_type": doc},
"max(modified)"
)
latest = max(
[
d for d in [
doctype_modified,
custom_field_modified,
property_setter_modified
] if d
],
default=None
)
if latest and last_sync and bool(getdate(latest) > getdate(last_sync)):
return True
return False
def is_doctype_schema_changed(doc, last_sync):
from frappe.utils import get_datetime

doctype_modified = frappe.db.get_value("DocType", doc, "modified")

custom_field_modified = frappe.db.sql(
"SELECT MAX(modified) FROM `tabCustom Field` WHERE dt = %s",
doc
)[0][0]

property_setter_modified = frappe.db.sql(
"SELECT MAX(modified) FROM `tabProperty Setter` WHERE doc_type = %s",
doc
)[0][0]

candidates = [
get_datetime(d) for d in [
doctype_modified,
custom_field_modified,
property_setter_modified
] if d
]

latest = max(candidates, default=None)
return bool(latest and last_sync and latest > get_datetime(last_sync))


def is_master_data_changed(last_sync):
from frappe.utils import get_datetime

for doc in MASTER_DOCTYPES:
latest_modified = frappe.db.get_value(
doc,
{},
"max(modified)"
)
return bool(getdate(latest_modified) > getdate(last_sync)) if latest_modified and last_sync else False
latest_modified = frappe.db.sql(
f"SELECT MAX(modified) FROM `tab{doc}`"
)[0][0]
if latest_modified and last_sync and get_datetime(latest_modified) > get_datetime(last_sync):
return True
return False


Expand Down
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
[project]
name = "changai"
authors = [
{ name = "ERpGulf", email = "support@erpgulf.com"}
{ name = "ERPGulf", email = "support@erpgulf.com"}
]
description = "ChangAI"
readme = "README.md"
dynamic = ["version"]
dependencies = [
"cffi",
"openai>=1.64.0,<2.0.0",
"anthropic>=0.79.0,<1.0.0",
"google-genai<2.0.0",
"openai",
"anthropic",
"google-genai",
"google-auth",
"google-cloud-aiplatform<2.0.0",
"google-cloud-aiplatform",
"langchain-core",
"langchain-community",
"langchain-huggingface",
"langgraph",
"symspellpy",
"transformers",
"sentence-transformers",
"faiss-cpu<2.0.0",
"faiss-cpu",
"numpy",
"sqlglot",
"boto3",
Expand Down
Loading