[api] make sure the night average calculation results in a float

This commit is contained in:
Bart Van Der Meerssche 2011-04-08 13:45:01 +00:00
parent b5c2759981
commit a71a0ede5a
1 changed files with 1 additions and 1 deletions

View File

@ -177,7 +177,7 @@ update_night(RrdSensor, Uid, Midnight, LastTimestamp, ReqData) when LastTimestam
{ok, Response} ->
Filtered = [re:split(X, "[:][ ]", [{return,list}]) || [X] <- Response, string:str(X, ":") == 11],
Datapoints = [list_to_float(Y) || [_X, Y] <- Filtered, string:len(Y) /= 3],
NightAverage = lists:foldl(fun(X, Sum) -> X / 12 + Sum end, 0, Datapoints),
NightAverage = lists:foldl(fun(X, Sum) -> X / 12 + Sum end, 0.0, Datapoints),
RrdData = [integer_to_list(LastMidnight + 5 * ?HOUR), ":", float_to_list(NightAverage)],
case rrd_update(?NIGHT_PATH, RrdSensor, RrdData) of