Skip to content

Commit

Permalink
fix: rm db
Browse files Browse the repository at this point in the history
  • Loading branch information
lsxredrain committed Nov 4, 2022
1 parent 9a0ceac commit 64c3c6e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion apps/dgiot_dlink/src/proctol/dgiot_mqtt_acl.erl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ description() -> "Acl with Dlink".
%% Internal functions
%%-------------------------------------------------------------------
do_check(#{username := <<"dgiot">>, clientid := ClientId}, _PubSub, _Topic) ->
io:format("~s ~p ClientId: ~p _Topic ~p ~n", [?FILE, ?LINE, ClientId, _Topic]),
%% io:format("~s ~p ClientId: ~p _Topic ~p ~n", [?FILE, ?LINE, ClientId, _Topic]),
SuperPwd = dgiot_utils:to_binary(dgiot:get_env(dgiot_dlink, super_pwd, <<"">>)),
case SuperPwd of
ClientId ->
Expand Down
4 changes: 2 additions & 2 deletions apps/dgiot_tdengine/src/dgiot_tdengine.erl
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ transaction(Channel, Fun) ->
get_database(ChannelId, ProductId) ->
case dgiot_data:get({tdengine_db, ChannelId, ProductId}) of
not_find ->
dgiot_tdengine_select:format_db(ProductId);
dgiot_tdengine_select:format_db(?Database(ProductId));
DbName ->
dgiot_tdengine_select:format_db(DbName)
dgiot_tdengine_select:format_db(?Database(DbName))
end.

create_database(DataBase, Keep) ->
Expand Down
7 changes: 3 additions & 4 deletions apps/dgiot_tdengine/src/utils/dgiot_tdengine_select.erl
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ format_db(DB) -> <<DB/binary, ".">>.

format_using(_, <<>>) -> <<>>;
format_using(DB, Table) ->
DB1 = format_db(DB),
<<" using ", DB1/binary, Table/binary>>.
<<" using ", DB/binary, Table/binary>>.

format_tags(<<>>) -> <<>>;
format_tags(Tags) -> <<" TAGS (", Tags/binary, ")">>.
Expand All @@ -54,13 +53,13 @@ format_batch(#{<<"db">> := DB, <<"tableName">> := TableName, <<"fields">> := _Fi
Using1 = format_using(DB, Using),
Tags = maps:get(<<"tags">>, Batch, []),
TagFields = format_tags(list_to_binary(dgiot_utils:join(",", Tags, false, fun format_value/1))),
<<DB/binary, ".",TableName/binary, Using1/binary, TagFields/binary, " VALUES ", Values0/binary>>;
<<DB/binary, TableName/binary, Using1/binary, TagFields/binary, " VALUES ", Values0/binary>>;
format_batch(#{<<"db">> := DB, <<"tableName">> := TableName, <<"values">> := Values0} = Batch) ->
Using = maps:get(<<"using">>, Batch, <<>>),
Using1 = format_using(DB, Using),
Tags = maps:get(<<"tags">>, Batch, []),
TagFields = format_tags(list_to_binary(dgiot_utils:join(",", Tags, false, fun format_value/1))),
<<DB/binary, ".",TableName/binary, Using1/binary, TagFields/binary, " VALUES ", Values0/binary>>.
<<DB/binary,TableName/binary, Using1/binary, TagFields/binary, " VALUES ", Values0/binary>>.

format_order([], Acc) -> Acc;
format_order([<<"-", Field/binary>> | Other], Acc) ->
Expand Down
4 changes: 2 additions & 2 deletions apps/dgiot_topo/src/dgiot_topo.erl
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ push(ProductId, Devaddr, DeviceId, Payload) ->
httpc:request(post, {Url1, [], "application/json", Data1}, [], []).

send_topo({NodeType, NodeId}, Token) ->
io:format("NodeType ~p NodeId ~p Token ~p ~n", [NodeType, NodeId,Token]),
%% io:format("NodeType ~p NodeId ~p Token ~p ~n", [NodeType, NodeId,Token]),
case dgiot_hook:run_hook({topo, NodeType, NodeId}, {Token, NodeId}) of
{ok, [{ok, Payload}]} ->
Base64 = base64:encode(jsx:encode(Payload)),
Pubtopic = <<"$dg/user/topo/", Token/binary, "/", NodeType/binary, "/", NodeId/binary, "/report">>,
io:format("~s ~p Pubtopic ~p Base64 ~p ~n", [?FILE,?LINE, Pubtopic, Base64]),
%% io:format("~s ~p Pubtopic ~p Base64 ~p ~n", [?FILE,?LINE, Pubtopic, Base64]),
dgiot_mqtt:publish(self(), Pubtopic, Base64);
_ ->
pass
Expand Down

0 comments on commit 64c3c6e

Please sign in to comment.