diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-02-18 15:04:19 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-02-18 15:04:19 +0100 |
commit | a805783f4bb2868e63ba49a911775fff30df5a07 (patch) | |
tree | 130c8ef970f9489876d0667eff25444a0816c41a /server | |
parent | c88197535f7a4c13b7464a785881a91a67ebd15b (diff) | |
download | thermoprint-a805783f4bb2868e63ba49a911775fff30df5a07.tar thermoprint-a805783f4bb2868e63ba49a911775fff30df5a07.tar.gz thermoprint-a805783f4bb2868e63ba49a911775fff30df5a07.tar.bz2 thermoprint-a805783f4bb2868e63ba49a911775fff30df5a07.tar.xz thermoprint-a805783f4bb2868e63ba49a911775fff30df5a07.zip |
Introduced Range
Diffstat (limited to 'server')
-rw-r--r-- | server/src/Thermoprint/Server/API.hs | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/server/src/Thermoprint/Server/API.hs b/server/src/Thermoprint/Server/API.hs index cd4326e..3f3ab46 100644 --- a/server/src/Thermoprint/Server/API.hs +++ b/server/src/Thermoprint/Server/API.hs | |||
@@ -141,16 +141,13 @@ printerStatus = fmap queueToStatus . queue' . snd <=< lookupPrinter . Just | |||
141 | queueToStatus (Queue _ (Just c) _) = Busy . castId $ jobId c | 141 | queueToStatus (Queue _ (Just c) _) = Busy . castId $ jobId c |
142 | 142 | ||
143 | listJobs :: Maybe PrinterId | 143 | listJobs :: Maybe PrinterId |
144 | -> Maybe API.JobId -> Maybe API.JobId | 144 | -> Maybe (Range API.JobId) -> Maybe (Range UTCTime) |
145 | -> Maybe UTCTime -> Maybe UTCTime | ||
146 | -> Handler (Seq (API.JobId, UTCTime, JobStatus)) | 145 | -> Handler (Seq (API.JobId, UTCTime, JobStatus)) |
147 | listJobs Nothing minId maxId minTime maxTime = fmap mconcat . mapM (\pId -> listJobs (Just pId) minId maxId minTime maxTime) =<< asks (Map.keys . printers) | 146 | listJobs Nothing idR timeR = fmap mconcat . mapM (\pId -> listJobs (Just pId) idR timeR) =<< asks (Map.keys . printers) |
148 | listJobs pId minId maxId minTime maxTime = fmap (filterJobs . extractJobs) . (\(a, b) -> (,) a <$> queue' b) =<< lookupPrinter pId | 147 | listJobs pId idR timeR = fmap (filterJobs . extractJobs) . (\(a, b) -> (,) a <$> queue' b) =<< lookupPrinter pId |
149 | where | 148 | where |
150 | filterJobs = Seq.filter (\(id, time, _) -> and ([ maybe True (<= id ) minId | 149 | filterJobs = Seq.filter (\(id, time, _) -> and ([ maybe True (`contains` id) idR |
151 | , maybe True (>= id ) maxId | 150 | , maybe True (`contains` time) timeR |
152 | , maybe True (<= time) minTime | ||
153 | , maybe True (>= time) maxTime | ||
154 | ] :: [Bool]) | 151 | ] :: [Bool]) |
155 | ) | 152 | ) |
156 | 153 | ||
@@ -158,7 +155,7 @@ getJob :: API.JobId -> Handler Printout | |||
158 | getJob jobId = fmap jobContent . maybe (left err404) return =<< runSqlPool (get $ castId jobId) =<< asks sqlPool | 155 | getJob jobId = fmap jobContent . maybe (left err404) return =<< runSqlPool (get $ castId jobId) =<< asks sqlPool |
159 | 156 | ||
160 | jobStatus :: API.JobId -> Handler JobStatus | 157 | jobStatus :: API.JobId -> Handler JobStatus |
161 | jobStatus jobId = maybe (left err404) return . lookup jobId . map (\(id, _, st) -> (id, st)) . toList =<< listJobs Nothing Nothing Nothing Nothing Nothing | 158 | jobStatus jobId = maybe (left err404) return . lookup jobId . map (\(id, _, st) -> (id, st)) . toList =<< listJobs Nothing Nothing Nothing |
162 | 159 | ||
163 | abortJob :: API.JobId -> Handler () | 160 | abortJob :: API.JobId -> Handler () |
164 | abortJob needle = do | 161 | abortJob needle = do |