reimplement JobOccurrence as newtype; add JSON and PersistField instances

This commit is contained in:
Sarah Vaupel 2023-11-21 21:37:11 +00:00
parent cacf2d291d
commit 1f7808ddf1
2 changed files with 13 additions and 4 deletions

View File

@ -1,5 +1,5 @@
-- Jobs to be fetched and distributed to the workers by the scheduler
-- part of the *new* job system
JobMeta
occurrence JobOccurrence default='{"dnf-terms":[]}' -- when should the job be executed? (Possibly recurring)
occurrence JobOccurrence -- when should the job be executed? (Possibly recurring)
deriving Eq Ord Show Generic

View File

@ -1,9 +1,18 @@
module Model.Types.Jobsystem
( JobOccurrence
( JobOccurrence(..)
) where
import Import.NoModel
type JobOccurrence = Occurrence LocalTime () -- latter is specialtime; not used yet
derivePersistFieldJSON ''Occurrence LocalTime ()
newtype JobOccurrence = JobOccurrence
{ jobOccurrence :: Occurrence LocalTime () -- latter is specialtime; not used yet
}
deriving (Eq, Ord, Read, Show, Generic)
deriving anyclass (NFData)
deriveJSON defaultOptions
{ tagSingleConstructors = False
, unwrapUnaryRecords = True
} ''JobOccurrence
derivePersistFieldJSON ''JobOccurrence