From bb0654201a4eddb79895f71544ce5d71e991f817 Mon Sep 17 00:00:00 2001 From: venkataakhil Date: Thu, 9 Feb 2023 16:51:16 +0530 Subject: [PATCH] Rate limit custom method --- smart_service/apis/master_api.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/smart_service/apis/master_api.py b/smart_service/apis/master_api.py index 340fc0f..a3ea878 100644 --- a/smart_service/apis/master_api.py +++ b/smart_service/apis/master_api.py @@ -1,7 +1,7 @@ # Copyright (c) 2021, Hard n Soft Technologies Pvt Ltd and contributors # For license information, please see license.txt -from frappe.rate_limiter import rate_limit +# from frappe.rate_limiter import rate_limit import frappe from frappe.model.document import Document @@ -12,11 +12,11 @@ from smart_service.apis.app_user_login import input_validation current_db_name = frappe.conf.get("db_name") -@frappe.whitelist(allow_guest=1) +@frappe.whitelist(allow_guest=True) def masters1(): - val = rate_limit(limit=5, seconds=10) - if val != 1: - return val + rate_res = rate_limit(limit=5, seconds=10) + if rate_res != 1: + return rate_res return 1 @@ -40,6 +40,10 @@ def rate_limit(limit, seconds): @frappe.whitelist() def masters(args=None, LSD=None): + rate = rate_limit(limit=5, seconds=5) + if rate != 1: + return rate + val = input_validation(args=args) if val != '': return {"status": 0, "error": "Parameter's missing:"+val}