-
Notifications
You must be signed in to change notification settings - Fork 814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add rule break support #73
base: master
Are you sure you want to change the base?
Conversation
risk_models/rule.py
Outdated
@@ -26,6 +26,7 @@ def __init__(self, d): | |||
self.id = d['id'] | |||
self.uuid = d['uuid'] | |||
self.name = d['title'] | |||
self.allow_break = d['allow_break'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里多了一个 ,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
另外是,需要兼容一下旧配置,此处应该给个默认值False
server/query.py
Outdated
control, weight = calculate_rule(rule_id, req_body, rules=rules, ac=ac) | ||
result = {'control': control, 'weight': weight} | ||
control, weight, custom = calculate_rule(rule_id, req_body, rules=rules, ac=ac) | ||
result = {'control': control, 'weight': weight, 'custom': custom} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个custom在目前的设计中不应该返回给业务方,这个主要是后续客服人员看的
www/rule/forms.py
Outdated
class RulesForm(BaseForm): | ||
title = forms.CharField(label=_(u"规则名称")) | ||
describe = forms.CharField(required=False, label=_(u"规则描述"), | ||
widget=forms.Textarea) | ||
status = forms.ChoiceField(label=_(u"状态"), choices=STATUS_CHOICES) | ||
#allow_break = PrettyCheckboxField(label=_(u"允许策略短路"), widget=PrettyCheckboxWidget()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 PrettyCheckboxField 如果没有用到的话,连同上面的一起全部删掉吧,减少无效代码量
risk_models/rule.py
Outdated
@@ -26,7 +26,7 @@ def __init__(self, d): | |||
self.id = d['id'] | |||
self.uuid = d['uuid'] | |||
self.name = d['title'] | |||
self.allow_break = d['allow_break'], | |||
self.allow_break = d['allow_break'] if 'allow_break' in d else False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个直接 d.get('auto_break', False) 就可以
www/rule/views.py
Outdated
@@ -265,6 +265,7 @@ def get_rule(self): | |||
x[2] for x in rule['strategy_list'] if len(x) == 3) | |||
rule['strategy_list_str'] = json.dumps(rule['strategy_list']) | |||
data['rule_list'] = rule_list | |||
data['allow_break'] = d['allow_break'] if 'allow_break' in d else False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这种也是,使用 d.get('auto_break', False)
更简略一些, 保险起见也可以d.get('auto_break') or False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
包括下面的一些地方
…hit strategy after a break logic
Increase the strategy short-circuit switch, allowing the subsequent strategy execution to be interrupted when the strategy hits