Browse Source

perf: 暂存一下

pull/10327/head
ibuler 2 years ago
parent
commit
197364d42d
  1. 19
      apps/common/db/fields.py
  2. 7
      apps/terminal/applets/chrome/app.py

19
apps/common/db/fields.py

@ -315,8 +315,7 @@ class RelatedManager:
else:
queryset = to_model.objects.all()
q = cls.get_filter_q(value, to_model)
print("Q: ", q)
return queryset.filter(q)
return queryset.filter(q).distinct()
@staticmethod
def get_ip_in_q(name, val):
@ -378,22 +377,12 @@ class RelatedManager:
q = Q(**{lookup: val})
elif match == "not":
q = ~Q(**{name: val})
elif match == "m2m":
elif match in ['m2m', 'in']:
if not isinstance(val, list):
val = [val]
q = Q(**{"{}__in".format(name): val})
elif match == "in" and isinstance(val, list):
if '*' not in val:
lookup = "{}__in".format(name)
q = Q(**{lookup: val})
else:
q = Q()
q = Q() if '*' in val else Q(**{"{}__in".format(name): val})
else:
if val == '*':
q = Q()
else:
q = Q(**{name: val})
q = Q() if val == '*' else Q(**{name: val})
filters &= q
return filters

7
apps/terminal/applets/chrome/app.py

@ -101,6 +101,7 @@ class StepAction:
else:
driver.switch_to.frame(target)
def execute_action(driver: webdriver.Chrome, step: StepAction) -> bool:
try:
return step.execute(driver)
@ -197,8 +198,10 @@ def default_chrome_driver_options():
# 禁用开发者工具
options.add_argument("--disable-dev-tools")
# 禁用 密码管理器弹窗
prefs = {"credentials_enable_service": False,
"profile.password_manager_enabled": False}
prefs = {
"credentials_enable_service": False,
"profile.password_manager_enabled": False
}
options.add_experimental_option("prefs", prefs)
options.add_experimental_option("excludeSwitches", ['enable-automation'])
return options

Loading…
Cancel
Save