X-Git-Url: http://www.average.org/gitweb/?p=pulsecounter.git;a=blobdiff_plain;f=web%2Fquery.cgi;h=f45c844ede55f9fbd540f6c6347f073e30c0f67b;hp=872023716d1cd12ecd43af9e6bcca7e76b2eed8f;hb=38ec11855134116dff6d9642b73207ca3134fcb2;hpb=57ab1d5776f832c3df5c8b2514f34e282b39fbd9 diff --git a/web/query.cgi b/web/query.cgi index 8720237..f45c844 100755 --- a/web/query.cgi +++ b/web/query.cgi @@ -48,16 +48,14 @@ cgiMain = do "select to_seconds(timestamp) as time, value+adj as value from \ \(select c.timestamp timestamp, c.value value, \ \(select sum(value) from coldadj a where a.timestamp <= c.timestamp \ - \) adj from coldcnt c \ - \where timestamp between ? and ? order by timestamp \ - \) t;" (slo, shi) + \) adj from coldcnt c where timestamp between ? and ? \ + \) t order by timestamp;" (slo, shi) hot <- liftIO $ query conn "select to_seconds(timestamp) as time, value+adj as value from \ \(select c.timestamp timestamp, c.value value, \ \(select sum(value) from hotadj a where a.timestamp <= c.timestamp \ - \) adj from hotcnt c \ - \where timestamp between ? and ? order by timestamp \ - \) t;" (slo, shi) + \) adj from hotcnt c where timestamp between ? and ? \ + \) t order by timestamp;" (slo, shi) [(ccold, chot)] <- liftIO $ query_ conn "select lcold+acold as cold, lhot+ahot as hot from \ \(select value as lcold from coldcnt order by timestamp desc limit 1) cc, \ @@ -71,7 +69,7 @@ cgiMain = do ++ ", \"hi\": " ++ show (ohi :: Int) ++ "}, \"current\": {\"cold\": " ++ show (floor (ccold :: Double)) ++ ", \"hot\": " ++ show (floor (chot :: Double)) - ++ "}}, \"cold\": [" ++ showjson cold + ++ "}, \"cold\": [" ++ showjson cold ++ "], \"hot\": [" ++ showjson hot ++ "]}\n" showjson :: [(Int, Double)] -> String