chore(job): add interface for sleep job adding
This commit is contained in:
parent
ee5a79398f
commit
a97dc071a3
@ -114,6 +114,11 @@ TableJobCreationInstance: Ersteller
|
|||||||
ActJobDelete: Job entfernen
|
ActJobDelete: Job entfernen
|
||||||
ActJobDeleteForce n@Int: Auch vor #{pluralDEnN n "Minute"} gesperrte Jobs entfernen
|
ActJobDeleteForce n@Int: Auch vor #{pluralDEnN n "Minute"} gesperrte Jobs entfernen
|
||||||
TableJobActDeleteFeedback n@Int m@Int: #{n}/#{m} Jobs entfernt
|
TableJobActDeleteFeedback n@Int m@Int: #{n}/#{m} Jobs entfernt
|
||||||
|
ActJobSleep: Test Job einreihen
|
||||||
|
JobSleepNr: Anzahl Jobs
|
||||||
|
JobSleepSecs: Laufzeit in Sekunden pro Job
|
||||||
|
JobSleepNow: Prioriäts-Jobs
|
||||||
|
TableJobActSleepFeedback n@Int sec@Int prio@Bool: #{n} #{bool tempty "Prioritäts-" prio}#{pluralDEx 's' n "Job"} mit #{sec}s Laufzeit eingereiht.
|
||||||
TableFilterComma: Es können mehrere alternative Suchkriterien mit Komma getrennt angegeben werden, wovon mindestens eines erfüllt werden muss.
|
TableFilterComma: Es können mehrere alternative Suchkriterien mit Komma getrennt angegeben werden, wovon mindestens eines erfüllt werden muss.
|
||||||
TableFilterCommaPlus: Mehrere alternative Suchkriterien mit Komma trennen. Mindestens ein Suchkriterium muss erfüllt werden, zusätzlich zu allen Suchkriterien mit vorangestelltem Plus-Symbol.
|
TableFilterCommaPlus: Mehrere alternative Suchkriterien mit Komma trennen. Mindestens ein Suchkriterium muss erfüllt werden, zusätzlich zu allen Suchkriterien mit vorangestelltem Plus-Symbol.
|
||||||
TableFilterCommaPlusShort: Unterstützt mehrere Kriterien mit Komma-Plus, siehe oben.
|
TableFilterCommaPlusShort: Unterstützt mehrere Kriterien mit Komma-Plus, siehe oben.
|
||||||
|
|||||||
@ -114,6 +114,11 @@ TableJobCreationInstance: Creator
|
|||||||
ActJobDelete: Delete job
|
ActJobDelete: Delete job
|
||||||
ActJobDeleteForce n: Also delete jobs locked #{pluralENsN n "minute"} ago
|
ActJobDeleteForce n: Also delete jobs locked #{pluralENsN n "minute"} ago
|
||||||
TableJobActDeleteFeedback n@Int m@Int: #{n}/#{m} queued jobs deleted
|
TableJobActDeleteFeedback n@Int m@Int: #{n}/#{m} queued jobs deleted
|
||||||
|
ActJobSleep: Enqueue sleep job
|
||||||
|
JobSleepNr: Number of jobs
|
||||||
|
JobSleepSecs: Seconds per job
|
||||||
|
JobSleepNow: Priority jobs
|
||||||
|
TableJobActSleepFeedback n@Int sec@Int prio@Bool: #{n} #{bool tempty "priority " prio} sleep #{pluralENs n "job"} for #{sec}s enqueued.
|
||||||
TableFilterComma: Separate multiple alternative filter criteria by comma, at least one of which must be fulfilled.
|
TableFilterComma: Separate multiple alternative filter criteria by comma, at least one of which must be fulfilled.
|
||||||
TableFilterCommaPlus: Separate multiple alternative filter criteria by comma, at least one of which must be fulfilled in addition to all criteria preceded by a plus symbol.
|
TableFilterCommaPlus: Separate multiple alternative filter criteria by comma, at least one of which must be fulfilled in addition to all criteria preceded by a plus symbol.
|
||||||
TableFilterCommaPlusShort: Support multiple criteria with comma/plus, see above.
|
TableFilterCommaPlusShort: Support multiple criteria with comma/plus, see above.
|
||||||
|
|||||||
@ -114,6 +114,7 @@ getAdminCrontabR = do
|
|||||||
|
|
||||||
|
|
||||||
data JobTableAction = ActJobDelete
|
data JobTableAction = ActJobDelete
|
||||||
|
| ActJobSleep
|
||||||
deriving (Eq, Ord, Enum, Bounded, Read, Show, Generic)
|
deriving (Eq, Ord, Enum, Bounded, Read, Show, Generic)
|
||||||
|
|
||||||
instance Universe JobTableAction
|
instance Universe JobTableAction
|
||||||
@ -121,9 +122,10 @@ instance Finite JobTableAction
|
|||||||
nullaryPathPiece ''JobTableAction $ camelToPathPiece' 1
|
nullaryPathPiece ''JobTableAction $ camelToPathPiece' 1
|
||||||
embedRenderMessage ''UniWorX ''JobTableAction id
|
embedRenderMessage ''UniWorX ''JobTableAction id
|
||||||
|
|
||||||
newtype JobTableActionData = ActJobDeleteData
|
data JobTableActionData
|
||||||
{ jobDeleteLocked :: Bool
|
= ActJobDeleteData { jobDeleteLocked :: Bool }
|
||||||
}
|
| ActJobSleepData { jobSleepNr, jobSleepSecs :: Int
|
||||||
|
, jobSleepNow :: Bool }
|
||||||
deriving (Eq, Ord, Read, Show, Generic)
|
deriving (Eq, Ord, Read, Show, Generic)
|
||||||
|
|
||||||
|
|
||||||
@ -168,9 +170,18 @@ postAdminJobsR = do
|
|||||||
prismAForm (singletonFilter "job" . maybePrism _PathPiece) mPrev $ aopt (hoistField lift textField) (fslI MsgTableJob)
|
prismAForm (singletonFilter "job" . maybePrism _PathPiece) mPrev $ aopt (hoistField lift textField) (fslI MsgTableJob)
|
||||||
]
|
]
|
||||||
dbtStyle = def { dbsFilterLayout = defaultDBSFilterLayout }
|
dbtStyle = def { dbsFilterLayout = defaultDBSFilterLayout }
|
||||||
|
|
||||||
|
areq_posIntF msg = areq (posIntFieldI $ SomeMessages " " [SomeMessage msg, SomeMessage MsgMustBePositive]) (fslI msg)
|
||||||
acts :: Map JobTableAction (AForm Handler JobTableActionData)
|
acts :: Map JobTableAction (AForm Handler JobTableActionData)
|
||||||
acts = Map.singleton ActJobDelete $ ActJobDeleteData
|
acts = Map.fromList
|
||||||
<$> areq checkBoxField (fslI $ MsgActJobDeleteForce jobDeleteLockMinutes) Nothing
|
[ (ActJobDelete, ActJobDeleteData
|
||||||
|
<$> areq checkBoxField (fslI $ MsgActJobDeleteForce jobDeleteLockMinutes) Nothing
|
||||||
|
),(ActJobSleep, ActJobSleepData
|
||||||
|
<$> areq_posIntF MsgJobSleepNr (Just 1)
|
||||||
|
<*> areq_posIntF MsgJobSleepSecs (Just 60)
|
||||||
|
<*> areq checkBoxField (fslI MsgJobSleepNow) (Just True)
|
||||||
|
)]
|
||||||
|
|
||||||
dbtParams = DBParamsForm
|
dbtParams = DBParamsForm
|
||||||
{ dbParamsFormAdditional =
|
{ dbParamsFormAdditional =
|
||||||
renderAForm FormStandard
|
renderAForm FormStandard
|
||||||
@ -196,7 +207,6 @@ postAdminJobsR = do
|
|||||||
(First (Just act), jobMap) <- inp
|
(First (Just act), jobMap) <- inp
|
||||||
let jobSet = Map.keysSet . Map.filter id $ getDBFormResult (const False) jobMap
|
let jobSet = Map.keysSet . Map.filter id $ getDBFormResult (const False) jobMap
|
||||||
return (act, jobSet)
|
return (act, jobSet)
|
||||||
void . queueJob' $ JobSleep 42 -- debug add sleep job
|
|
||||||
(jobActRes, jobsTable) <- runDB (over _1 postprocess <$> dbTable jobsDBTableValidator jobsDBTable)
|
(jobActRes, jobsTable) <- runDB (over _1 postprocess <$> dbTable jobsDBTableValidator jobsDBTable)
|
||||||
|
|
||||||
formResult jobActRes $ \case
|
formResult jobActRes $ \case
|
||||||
@ -219,6 +229,13 @@ postAdminJobsR = do
|
|||||||
addMessageI (bool Success Warning $ rmvd < jobReq) (MsgTableJobActDeleteFeedback rmvd jobReq)
|
addMessageI (bool Success Warning $ rmvd < jobReq) (MsgTableJobActDeleteFeedback rmvd jobReq)
|
||||||
reloadKeepGetParams AdminJobsR
|
reloadKeepGetParams AdminJobsR
|
||||||
|
|
||||||
|
(ActJobSleepData{..}, _) -> do
|
||||||
|
let jSleep = JobSleep jobSleepSecs
|
||||||
|
enqSleep = bool (void . queueJob) queueJob' jobSleepNow jSleep
|
||||||
|
replicateM_ jobSleepNr enqSleep
|
||||||
|
addMessageI Success (MsgTableJobActSleepFeedback jobSleepNr jobSleepSecs jobSleepNow)
|
||||||
|
reloadKeepGetParams AdminJobsR
|
||||||
|
|
||||||
-- gather some data on job worles
|
-- gather some data on job worles
|
||||||
(nrWorkers, jobStateVar) <- getsYesod (view _appJobWorkers &&& appJobState)
|
(nrWorkers, jobStateVar) <- getsYesod (view _appJobWorkers &&& appJobState)
|
||||||
jState <- atomically $ tryReadTMVar jobStateVar
|
jState <- atomically $ tryReadTMVar jobStateVar
|
||||||
|
|||||||
@ -274,6 +274,10 @@ addAttrsClass cl attrs = ("class", cl') : noClAttrs
|
|||||||
-- tickmark :: IsString a => a
|
-- tickmark :: IsString a => a
|
||||||
-- tickmark = fromString "✔"
|
-- tickmark = fromString "✔"
|
||||||
|
|
||||||
|
-- | to conveniently avoid some ambiguous type problems
|
||||||
|
tempty :: Text
|
||||||
|
tempty = mempty
|
||||||
|
|
||||||
nonBreakableDash :: Text -- used directly in several messages
|
nonBreakableDash :: Text -- used directly in several messages
|
||||||
nonBreakableDash = "‑"
|
nonBreakableDash = "‑"
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user