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