Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

flyer5200
Copy link

Increase the strategy short-circuit switch, allowing the subsequent strategy execution to be interrupted when the strategy hits

@@ -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'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里多了一个 ,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外是,需要兼容一下旧配置,此处应该给个默认值False

risk_models/rule.py Outdated Show resolved Hide resolved
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}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个custom在目前的设计中不应该返回给业务方,这个主要是后续客服人员看的

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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 PrettyCheckboxField 如果没有用到的话,连同上面的一起全部删掉吧,减少无效代码量

@@ -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
Copy link
Contributor

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) 就可以

@@ -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
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

包括下面的一些地方

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants