From ac1e272fb54341ea4ffd6f55a91955a971c7ddd4 Mon Sep 17 00:00:00 2001 From: Sarah Vaupel Date: Thu, 30 Nov 2023 00:19:47 +0000 Subject: [PATCH] chore(jobsystem): add ressource model representation --- models/jobsystem.model | 1 + src/Model/Types/Jobsystem.hs | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/models/jobsystem.model b/models/jobsystem.model index 3b5690da1..a5b0902f2 100644 --- a/models/jobsystem.model +++ b/models/jobsystem.model @@ -4,6 +4,7 @@ JobMeta occurrence JobOccurrence -- When should the job be executed? -- (Possibly recurring) + ressources JobRessources deriving Eq Ord Show Generic -- Actual job to be fetched and executed by the workers diff --git a/src/Model/Types/Jobsystem.hs b/src/Model/Types/Jobsystem.hs index ffbfea8c2..4082a3372 100644 --- a/src/Model/Types/Jobsystem.hs +++ b/src/Model/Types/Jobsystem.hs @@ -1,5 +1,6 @@ module Model.Types.Jobsystem ( JobOccurrence(..) + , JobRessource(..), JobRessources(..) ) where import Import.NoModel @@ -16,3 +17,25 @@ deriveJSON defaultOptions , unwrapUnaryRecords = True } ''JobOccurrence derivePersistFieldJSON ''JobOccurrence + + +data JobRessource + = JobResCPU + | JobResMemory + | JobResPrinter + deriving (Eq, Ord, Enum, Bounded, Read, Show, Generic) + deriving anyclass (Universe, Finite, NFData) + +nullaryPathPiece ''JobRessource $ camelToPathPiece' 2 +pathPieceJSON ''JobRessource +pathPieceJSONKey ''JobRessource + +newtype JobRessources = JobRessources { jobRessources :: Map JobRessource Double } + deriving (Eq, Ord, Read, Show, Generic) + deriving anyclass (NFData) + +deriveJSON defaultOptions + { tagSingleConstructors = False + , unwrapUnaryRecords = True + } ''JobRessources +derivePersistFieldJSON ''JobRessources