fix device query
This commit is contained in:
parent
c8142256e8
commit
a3f7590341
@ -80,8 +80,8 @@ handle_request("POST", "/device/query", _, Params = #{<<"device_uuid">> := Devic
|
||||
|
||||
true ->
|
||||
{ok, DeviceDataList} = iot_device:query(DevicePid, Tags, StartTs, StopTs, Limit),
|
||||
DataItems = lists:map(fun(#device_data{tags = Tags, val = Val, timestamp = Timestamp}) ->
|
||||
#{<<"tags">> => Tags, <<"val">> => Val, <<"timestamp">> => Timestamp}
|
||||
DataItems = lists:map(fun(#device_data{tags = Tags0, val = Val, timestamp = Timestamp}) ->
|
||||
#{<<"tags">> => Tags0, <<"val">> => Val, <<"timestamp">> => Timestamp}
|
||||
end, DeviceDataList),
|
||||
{ok, 200, iot_util:json_data(DataItems)};
|
||||
false ->
|
||||
@ -91,4 +91,4 @@ handle_request("POST", "/device/query", _, Params = #{<<"device_uuid">> := Devic
|
||||
|
||||
handle_request(_, Path, _, _) ->
|
||||
Path1 = list_to_binary(Path),
|
||||
{ok, 200, iot_util:json_error(-1, <<"url: ", Path1/binary, " not found">>)}.
|
||||
{ok, 200, iot_util:json_error(-1, <<"url: ", Path1/binary, " not found">>)}.
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
% "timestamp": int
|
||||
%}
|
||||
%],
|
||||
-spec serialize(FieldsList :: [map()]) -> [Val :: binary()].
|
||||
-spec serialize(FieldsList :: [map()]) -> [Val :: map()].
|
||||
serialize(FieldsList) when is_list(FieldsList) ->
|
||||
lists:flatmap(fun serialize0/1, FieldsList).
|
||||
serialize0(Fields = #{<<"key">> := Key}) when is_binary(Key) andalso Key /= <<>> ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user