fix(rule): rename enabled to enable
This commit is contained in:
parent
cfaad15364
commit
a9c9d9d805
|
@ -47,7 +47,7 @@
|
||||||
, name := binary()
|
, name := binary()
|
||||||
, sql := binary()
|
, sql := binary()
|
||||||
, outputs := [output()]
|
, outputs := [output()]
|
||||||
, enabled := boolean()
|
, enable := boolean()
|
||||||
, description => binary()
|
, description => binary()
|
||||||
, created_at := integer() %% epoch in millisecond precision
|
, created_at := integer() %% epoch in millisecond precision
|
||||||
, from := list(topic())
|
, from := list(topic())
|
||||||
|
|
|
@ -223,7 +223,7 @@ do_create_rule(Params = #{id := RuleId, sql := Sql, outputs := Outputs}) ->
|
||||||
id => RuleId,
|
id => RuleId,
|
||||||
name => maps:get(name, Params, <<"">>),
|
name => maps:get(name, Params, <<"">>),
|
||||||
created_at => erlang:system_time(millisecond),
|
created_at => erlang:system_time(millisecond),
|
||||||
enabled => maps:get(enabled, Params, true),
|
enable => maps:get(enable, Params, true),
|
||||||
sql => Sql,
|
sql => Sql,
|
||||||
outputs => parse_outputs(Outputs),
|
outputs => parse_outputs(Outputs),
|
||||||
description => maps:get(description, Params, ""),
|
description => maps:get(description, Params, ""),
|
||||||
|
|
|
@ -197,8 +197,8 @@ param_path_id() ->
|
||||||
{404, #{code => 'NOT_FOUND', message => <<"Rule Id Not Found">>}}
|
{404, #{code => 'NOT_FOUND', message => <<"Rule Id Not Found">>}}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
'/rules/:id'(put, #{bindings := #{id := Id}, body := Params}) ->
|
'/rules/:id'(put, #{bindings := #{id := Id}, body := Params0}) ->
|
||||||
Params = filter_out_request_body(Params),
|
Params = filter_out_request_body(Params0),
|
||||||
ConfPath = emqx_rule_engine:config_key_path() ++ [Id],
|
ConfPath = emqx_rule_engine:config_key_path() ++ [Id],
|
||||||
case emqx:update_config(ConfPath, Params, #{}) of
|
case emqx:update_config(ConfPath, Params, #{}) of
|
||||||
{ok, #{post_config_update := #{emqx_rule_engine := AllRules}}} ->
|
{ok, #{post_config_update := #{emqx_rule_engine := AllRules}}} ->
|
||||||
|
@ -235,7 +235,7 @@ format_rule_resp(#{ id := Id, name := Name,
|
||||||
from := Topics,
|
from := Topics,
|
||||||
outputs := Output,
|
outputs := Output,
|
||||||
sql := SQL,
|
sql := SQL,
|
||||||
enabled := Enabled,
|
enable := Enable,
|
||||||
description := Descr}) ->
|
description := Descr}) ->
|
||||||
NodeMetrics = get_rule_metrics(Id),
|
NodeMetrics = get_rule_metrics(Id),
|
||||||
#{id => Id,
|
#{id => Id,
|
||||||
|
@ -245,7 +245,7 @@ format_rule_resp(#{ id := Id, name := Name,
|
||||||
sql => SQL,
|
sql => SQL,
|
||||||
metrics => aggregate_metrics(NodeMetrics),
|
metrics => aggregate_metrics(NodeMetrics),
|
||||||
node_metrics => NodeMetrics,
|
node_metrics => NodeMetrics,
|
||||||
enabled => Enabled,
|
enable => Enable,
|
||||||
created_at => format_datetime(CreatedAt, millisecond),
|
created_at => format_datetime(CreatedAt, millisecond),
|
||||||
description => Descr
|
description => Descr
|
||||||
}.
|
}.
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
-spec(apply_rules(list(rule()), input()) -> ok).
|
-spec(apply_rules(list(rule()), input()) -> ok).
|
||||||
apply_rules([], _Input) ->
|
apply_rules([], _Input) ->
|
||||||
ok;
|
ok;
|
||||||
apply_rules([#{enabled := false}|More], Input) ->
|
apply_rules([#{enable := false}|More], Input) ->
|
||||||
apply_rules(More, Input);
|
apply_rules(More, Input);
|
||||||
apply_rules([Rule = #{id := RuleID}|More], Input) ->
|
apply_rules([Rule = #{id := RuleID}|More], Input) ->
|
||||||
try apply_rule_discard_result(Rule, Input)
|
try apply_rule_discard_result(Rule, Input)
|
||||||
|
|
|
@ -47,7 +47,7 @@ test_rule(Sql, Select, Context, EventTopics) ->
|
||||||
sql => Sql,
|
sql => Sql,
|
||||||
from => EventTopics,
|
from => EventTopics,
|
||||||
outputs => [#{mod => ?MODULE, func => get_selected_data, args => #{}}],
|
outputs => [#{mod => ?MODULE, func => get_selected_data, args => #{}}],
|
||||||
enabled => true,
|
enable => true,
|
||||||
is_foreach => emqx_rule_sqlparser:select_is_foreach(Select),
|
is_foreach => emqx_rule_sqlparser:select_is_foreach(Select),
|
||||||
fields => emqx_rule_sqlparser:select_fields(Select),
|
fields => emqx_rule_sqlparser:select_fields(Select),
|
||||||
doeach => emqx_rule_sqlparser:select_doeach(Select),
|
doeach => emqx_rule_sqlparser:select_doeach(Select),
|
||||||
|
|
Loading…
Reference in New Issue