[api] take care of uid=0 condition
This commit is contained in:
parent
624c292684
commit
b5c2759981
|
@ -198,8 +198,14 @@ update_night(_RrdSensor, _Uid, Midnight, _LastTimestamp, _ReqData) ->
|
||||||
|
|
||||||
calculate_midnight(Timestamp, Uid) ->
|
calculate_midnight(Timestamp, Uid) ->
|
||||||
{data, Result} = mysql:execute(pool, timezone, [Uid]),
|
{data, Result} = mysql:execute(pool, timezone, [Uid]),
|
||||||
[[TimezoneChar8]] = mysql:get_result_rows(Result),
|
|
||||||
Timezone = list_to_integer(binary_to_list(TimezoneChar8)),
|
case mysql:get_result_rows(Result) of
|
||||||
|
[[undefined]] ->
|
||||||
|
Timezone = 0;
|
||||||
|
[[TimezoneChar8]] ->
|
||||||
|
Timezone = list_to_integer(binary_to_list(TimezoneChar8))
|
||||||
|
end,
|
||||||
|
|
||||||
closest_midnight(trunc(Timestamp/?DAY + 1) * ?DAY - Timezone, Timestamp).
|
closest_midnight(trunc(Timestamp/?DAY + 1) * ?DAY - Timezone, Timestamp).
|
||||||
|
|
||||||
closest_midnight(ProposedMidnight, Timestamp) when ProposedMidnight > Timestamp ->
|
closest_midnight(ProposedMidnight, Timestamp) when ProposedMidnight > Timestamp ->
|
||||||
|
|
Loading…
Reference in New Issue