Revert "perf: Avoid checking server script map (#29057)"
This reverts commit 55a55e7f7b.
This commit is contained in:
parent
c76b23a050
commit
dfc6dcb6b8
3 changed files with 9 additions and 21 deletions
|
|
@ -9,7 +9,6 @@ Note:
|
|||
"""
|
||||
|
||||
import json
|
||||
from contextlib import suppress
|
||||
from typing import Any
|
||||
|
||||
from werkzeug.routing import Rule
|
||||
|
|
@ -39,15 +38,10 @@ def handle_rpc_call(method: str, doctype: str | None = None):
|
|||
method = hook
|
||||
break
|
||||
|
||||
method_exists = False
|
||||
with suppress(Exception):
|
||||
method_exists = bool(frappe.get_attr(method))
|
||||
|
||||
# via server script
|
||||
if not method_exists:
|
||||
server_script = get_server_script_map().get("_api", {}).get(method)
|
||||
if server_script:
|
||||
return run_server_script(server_script)
|
||||
server_script = get_server_script_map().get("_api", {}).get(method)
|
||||
if server_script:
|
||||
return run_server_script(server_script)
|
||||
|
||||
try:
|
||||
method = frappe.get_attr(method)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
|
||||
import os
|
||||
from contextlib import suppress
|
||||
from mimetypes import guess_type
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
|
|
@ -67,15 +66,10 @@ def execute_cmd(cmd, from_async=False):
|
|||
cmd = hook
|
||||
break
|
||||
|
||||
method_exists = False
|
||||
with suppress(Exception):
|
||||
method_exists = bool(get_attr(cmd))
|
||||
|
||||
# via server script
|
||||
if not method_exists:
|
||||
server_script = get_server_script_map().get("_api", {}).get(cmd)
|
||||
if server_script:
|
||||
return run_server_script(server_script)
|
||||
server_script = get_server_script_map().get("_api", {}).get(cmd)
|
||||
if server_script:
|
||||
return run_server_script(server_script)
|
||||
|
||||
try:
|
||||
method = get_attr(cmd)
|
||||
|
|
|
|||
|
|
@ -291,20 +291,20 @@ class TestOverheadCalls(FrappeAPITestCase):
|
|||
|
||||
def test_ping_overheads(self):
|
||||
self.get(self.method("ping"), {"sid": "Guest"})
|
||||
with self.assertRedisCallCounts(9), self.assertQueryCount(self.BASE_SQL_CALLS):
|
||||
with self.assertRedisCallCounts(10), self.assertQueryCount(self.BASE_SQL_CALLS):
|
||||
self.get(self.method("ping"), {"sid": "Guest"})
|
||||
|
||||
def test_ping_overheads_authenticated(self):
|
||||
sid = self.sid
|
||||
self.get(self.method("ping"), {"sid": sid})
|
||||
with self.assertRedisCallCounts(9), self.assertQueryCount(self.BASE_SQL_CALLS):
|
||||
with self.assertRedisCallCounts(10), self.assertQueryCount(self.BASE_SQL_CALLS):
|
||||
self.get(self.method("ping"), {"sid": sid})
|
||||
|
||||
def test_list_view_overheads(self):
|
||||
sid = self.sid
|
||||
self.get(self.resource("ToDo"), {"sid": sid})
|
||||
self.get(self.resource("ToDo"), {"sid": sid})
|
||||
with self.assertRedisCallCounts(16), self.assertQueryCount(self.BASE_SQL_CALLS + 1):
|
||||
with self.assertRedisCallCounts(24), self.assertQueryCount(self.BASE_SQL_CALLS + 1):
|
||||
self.get(self.resource("ToDo"), {"sid": sid})
|
||||
|
||||
def test_get_doc_overheads(self):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue