LGTM, thanks.
On Thu, Jan 23, 2014 at 11:01 PM, Klaus Aehlig <[email protected]> wrote: > Jobs usually are archived a given time after they have finished. > For finalized jobs without end-time, the start-time is taken en > lieu. This function provides the pure predicate for this decision. > > Signed-off-by: Klaus Aehlig <[email protected]> > --- > src/Ganeti/JQueue.hs | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/src/Ganeti/JQueue.hs b/src/Ganeti/JQueue.hs > index 8afefab..3ab72ee 100644 > --- a/src/Ganeti/JQueue.hs > +++ b/src/Ganeti/JQueue.hs > @@ -41,6 +41,7 @@ module Ganeti.JQueue > , calcJobStatus > , jobStarted > , jobFinalized > + , jobArchivable > , calcJobPriority > , jobFileName > , liveJobFile > @@ -60,6 +61,7 @@ module Ganeti.JQueue > , cancelJob > ) where > > +import Control.Applicative (liftA2, (<|>)) > import Control.Arrow (second) > import Control.Concurrent.MVar > import Control.Exception > @@ -272,6 +274,13 @@ jobStarted = (> JOB_STATUS_QUEUED) . calcJobStatus > jobFinalized :: QueuedJob -> Bool > jobFinalized = (> JOB_STATUS_RUNNING) . calcJobStatus > > +-- | Determine if a job is finalized and its timestamp is before > +-- a given time. > +jobArchivable :: Timestamp -> QueuedJob -> Bool > +jobArchivable ts = liftA2 (&&) jobFinalized > + $ maybe False (< ts) > + . liftA2 (<|>) qjEndTimestamp qjStartTimestamp > + > -- | Determine whether an opcode status is finalized. > opStatusFinalized :: OpStatus -> Bool > opStatusFinalized = (> OP_STATUS_RUNNING) > -- > 1.8.5.3 > >
