fix(mgmt): convert timestamp to milliseconds
This commit is contained in:
parent
9cf03bb18a
commit
d6f56cbcbe
|
@ -297,10 +297,12 @@ to_integer(I) when is_integer(I) ->
|
||||||
to_integer(B) when is_binary(B) ->
|
to_integer(B) when is_binary(B) ->
|
||||||
binary_to_integer(B).
|
binary_to_integer(B).
|
||||||
|
|
||||||
|
%% @doc The input timestamp time is in seconds, which needs to be
|
||||||
|
%% converted to internal milliseconds here
|
||||||
to_timestamp(I) when is_integer(I) ->
|
to_timestamp(I) when is_integer(I) ->
|
||||||
I;
|
I * 1000;
|
||||||
to_timestamp(B) when is_binary(B) ->
|
to_timestamp(B) when is_binary(B) ->
|
||||||
binary_to_integer(B).
|
binary_to_integer(B) * 1000.
|
||||||
|
|
||||||
aton(B) when is_binary(B) ->
|
aton(B) when is_binary(B) ->
|
||||||
list_to_tuple([binary_to_integer(T) || T <- re:split(B, "[.]")]).
|
list_to_tuple([binary_to_integer(T) || T <- re:split(B, "[.]")]).
|
||||||
|
@ -332,7 +334,7 @@ params2qs_test() ->
|
||||||
ExpectedQs = [{str, '=:=', <<"abc">>},
|
ExpectedQs = [{str, '=:=', <<"abc">>},
|
||||||
{int, '=:=', 123},
|
{int, '=:=', 123},
|
||||||
{atom, '=:=', connected},
|
{atom, '=:=', connected},
|
||||||
{ts, '=:=', 156000},
|
{ts, '=:=', 156000000},
|
||||||
{range, '>=', 1, '=<', 5}
|
{range, '>=', 1, '=<', 5}
|
||||||
],
|
],
|
||||||
FuzzyQs = [{fuzzy, like, <<"user">>},
|
FuzzyQs = [{fuzzy, like, <<"user">>},
|
||||||
|
|
|
@ -435,10 +435,10 @@ params2qs_test() ->
|
||||||
proto_ver => 4,
|
proto_ver => 4,
|
||||||
connected_at => '$3'},
|
connected_at => '$3'},
|
||||||
session => #{created_at => '$2'}},
|
session => #{created_at => '$2'}},
|
||||||
ExpectedCondi = [{'>=','$2', 1},
|
ExpectedCondi = [{'>=','$2', 1000},
|
||||||
{'=<','$2', 5},
|
{'=<','$2', 5000},
|
||||||
{'>=','$3', 1},
|
{'>=','$3', 1000},
|
||||||
{'=<','$3', 5}],
|
{'=<','$3', 5000}],
|
||||||
{10, {Qs1, []}} = emqx_mgmt_api:params2qs(Params, QsSchema),
|
{10, {Qs1, []}} = emqx_mgmt_api:params2qs(Params, QsSchema),
|
||||||
[{{'$1', MtchHead, _}, Condi, _}] = qs2ms(Qs1),
|
[{{'$1', MtchHead, _}, Condi, _}] = qs2ms(Qs1),
|
||||||
?assertEqual(ExpectedMtchHead, MtchHead),
|
?assertEqual(ExpectedMtchHead, MtchHead),
|
||||||
|
|
Loading…
Reference in New Issue