chore(workflows): introduce _index.yaml
This commit is contained in:
parent
c157c93ac7
commit
6c600daf2b
@ -38,11 +38,26 @@ import qualified Data.Yaml as Yaml
|
||||
import Utils.Workflow
|
||||
import Utils.Workflow.Lint
|
||||
|
||||
import System.Directory (getModificationTime)
|
||||
import System.Directory (getModificationTime, doesFileExist)
|
||||
import System.FilePath.Glob (glob)
|
||||
|
||||
import System.IO (hPutStrLn)
|
||||
|
||||
import qualified Data.List.NonEmpty as NonEmpty
|
||||
|
||||
|
||||
data WorkflowIndexItem = WorkflowIndexItem
|
||||
{ wiiGraphFile :: FilePath
|
||||
, wiiCategory :: Maybe WorkflowInstanceCategory
|
||||
, wiiDefinitionScope :: WorkflowScope'
|
||||
, wiiDefinitionDescription :: Maybe (I18n (Text, Maybe StoredMarkup))
|
||||
, wiiInstanceDescription :: Maybe (I18n (Text, Maybe StoredMarkup))
|
||||
, wiiInstances :: Set RouteWorkflowScope
|
||||
}
|
||||
deriveJSON defaultOptions
|
||||
{ fieldLabelModifier = camelToPathPiece' 1
|
||||
} ''WorkflowIndexItem
|
||||
|
||||
|
||||
testdataDir :: FilePath
|
||||
testdataDir = "testdata"
|
||||
@ -1397,82 +1412,41 @@ fillDb = do
|
||||
|
||||
liftIO . LBS.writeFile (testdataDir </> "bigAlloc_ordinal.csv") $ Csv.encode ordinalPriorities
|
||||
|
||||
let displayLinterIssue :: MonadIO m => WorkflowGraphLinterIssue -> m ()
|
||||
displayLinterIssue = liftIO . hPutStrLn stderr . displayException
|
||||
whenM (liftIO . doesFileExist $ testdataDir </> "workflows" </> "_index.yaml") $ do
|
||||
let displayLinterIssue :: MonadIO m => WorkflowGraphLinterIssue -> m ()
|
||||
displayLinterIssue = liftIO . hPutStrLn stderr . displayException
|
||||
|
||||
handleSql displayLinterIssue $ do
|
||||
graph <- Yaml.decodeFileThrow $ testdataDir </> "workflows" </> "theses.yaml"
|
||||
for_ (lintWorkflowGraph graph) $ mapM_ throwM
|
||||
workflowDefinitionGraph <- insertSharedWorkflowGraph graph
|
||||
let
|
||||
thesesWorkflowDef = WorkflowDefinition{..}
|
||||
where workflowDefinitionInstanceCategory = Just "theses"
|
||||
workflowDefinitionName = "theses"
|
||||
workflowDefinitionScope = WSSchool'
|
||||
wdId <- insert thesesWorkflowDef
|
||||
insert_ WorkflowDefinitionDescription
|
||||
{ workflowDefinitionDescriptionDefinition = wdId
|
||||
, workflowDefinitionDescriptionLanguage = "de-de-formal"
|
||||
, workflowDefinitionDescriptionTitle = "Abschlussarbeiten"
|
||||
, workflowDefinitionDescriptionDescription = Just "Erlaubt Abschlussarbeiten in Uni2work zu verwalten"
|
||||
}
|
||||
insert_ WorkflowDefinitionInstanceDescription
|
||||
{ workflowDefinitionInstanceDescriptionDefinition = wdId
|
||||
, workflowDefinitionInstanceDescriptionLanguage = "de-de-formal"
|
||||
, workflowDefinitionInstanceDescriptionTitle = "Abschlussarbeiten"
|
||||
, workflowDefinitionInstanceDescriptionDescription = Just "Hier können Sie Abschlussarbeiten bei der Prüfungsverwaltung angemeldet werden, der relevante Student die Arbeit digital abgeben und im Anschluss auch die Benotung an die Prüfungsverwaltung übermittelt werden."
|
||||
}
|
||||
let
|
||||
thesesWorkflowInst = WorkflowInstance{..}
|
||||
where workflowInstanceDefinition = Just wdId
|
||||
workflowInstanceGraph = workflowDefinitionGraph
|
||||
workflowInstanceScope = WSSchool $ unSchoolKey ifi
|
||||
workflowInstanceName = workflowDefinitionName thesesWorkflowDef
|
||||
workflowInstanceCategory = workflowDefinitionInstanceCategory thesesWorkflowDef
|
||||
wiId <- insert thesesWorkflowInst
|
||||
insert_ WorkflowInstanceDescription
|
||||
{ workflowInstanceDescriptionInstance = wiId
|
||||
, workflowInstanceDescriptionLanguage = "de-de-formal"
|
||||
, workflowInstanceDescriptionTitle = "Abschlussarbeiten"
|
||||
, workflowInstanceDescriptionDescription = Just "Hier können Sie Abschlussarbeiten bei der Prüfungsverwaltung angemeldet werden, der relevante Student die Arbeit digital abgeben und im Anschluss auch die Benotung an die Prüfungsverwaltung übermittelt werden."
|
||||
}
|
||||
wfIndex <- Yaml.decodeFileThrow @_ @(Map WorkflowDefinitionName WorkflowIndexItem) $ testdataDir </> "workflows" </> "_index.yaml"
|
||||
|
||||
handleSql displayLinterIssue $ do
|
||||
graph <- Yaml.decodeFileThrow $ testdataDir </> "workflows" </> "recognitions-ifi.yaml"
|
||||
for_ (lintWorkflowGraph graph) $ mapM_ throwM
|
||||
workflowDefinitionGraph <- insertSharedWorkflowGraph graph
|
||||
let
|
||||
recognitionsWorkflowDef = WorkflowDefinition{..}
|
||||
where workflowDefinitionInstanceCategory = Just "recognitions-ifi"
|
||||
workflowDefinitionName = "recognitions-ifi"
|
||||
workflowDefinitionScope = WSSchool'
|
||||
wdId <- insert recognitionsWorkflowDef
|
||||
insert_ WorkflowDefinitionDescription
|
||||
{ workflowDefinitionDescriptionDefinition = wdId
|
||||
, workflowDefinitionDescriptionLanguage = "de-de-formal"
|
||||
, workflowDefinitionDescriptionTitle = "Anerkennungen"
|
||||
, workflowDefinitionDescriptionDescription = Just "Erlaubt Anerkennungen von Leistungen in Uni2work zu verwalten"
|
||||
}
|
||||
insert_ WorkflowDefinitionInstanceDescription
|
||||
{ workflowDefinitionInstanceDescriptionDefinition = wdId
|
||||
, workflowDefinitionInstanceDescriptionLanguage = "de-de-formal"
|
||||
, workflowDefinitionInstanceDescriptionTitle = "Anerekennungen"
|
||||
, workflowDefinitionInstanceDescriptionDescription = Nothing
|
||||
}
|
||||
let
|
||||
recognitionsWorkflowInst = WorkflowInstance{..}
|
||||
where workflowInstanceDefinition = Just wdId
|
||||
iforM_ wfIndex $ \wiName WorkflowIndexItem{..} -> handleSql displayLinterIssue $ do
|
||||
graph <- Yaml.decodeFileThrow $ testdataDir </> "workflows" </> wiiGraphFile
|
||||
for_ (lintWorkflowGraph graph) $ mapM_ throwM
|
||||
workflowDefinitionGraph <- insertSharedWorkflowGraph graph
|
||||
let workflowDef = WorkflowDefinition{..}
|
||||
where workflowDefinitionInstanceCategory = wiiCategory
|
||||
workflowDefinitionName = wiName
|
||||
workflowDefinitionScope = wiiDefinitionScope
|
||||
wdId <- insert workflowDef
|
||||
let descs = maybe Map.empty (\I18n{..} -> Map.insert (fromMaybe (NonEmpty.head appLanguages) i18nFallbackLang) i18nFallback i18nTranslations) wiiDefinitionDescription
|
||||
iDescs = maybe Map.empty (\I18n{..} -> Map.insert (fromMaybe (NonEmpty.head appLanguages) i18nFallbackLang) i18nFallback i18nTranslations) wiiInstanceDescription
|
||||
iforM_ descs $ \workflowDefinitionDescriptionLanguage (workflowDefinitionDescriptionTitle, workflowDefinitionDescriptionDescription) ->
|
||||
let workflowDefinitionDescriptionDefinition = wdId
|
||||
in insert_ WorkflowDefinitionDescription{..}
|
||||
iforM_ iDescs $ \workflowDefinitionInstanceDescriptionLanguage (workflowDefinitionInstanceDescriptionTitle, workflowDefinitionInstanceDescriptionDescription) ->
|
||||
let workflowDefinitionInstanceDescriptionDefinition = wdId
|
||||
in insert_ WorkflowDefinitionInstanceDescription{..}
|
||||
forM_ wiiInstances $ \rScope -> do
|
||||
dbScope <- fmap (view _DBWorkflowScope) . maybeT (error $ "Could not resolve scope: " <> show rScope) $ fromRouteWorkflowScope rScope
|
||||
wiId <-
|
||||
let workflowInstanceDefinition = Just wdId
|
||||
workflowInstanceGraph = workflowDefinitionGraph
|
||||
workflowInstanceScope = WSSchool $ unSchoolKey ifi
|
||||
workflowInstanceName = workflowDefinitionName recognitionsWorkflowDef
|
||||
workflowInstanceCategory = workflowDefinitionInstanceCategory recognitionsWorkflowDef
|
||||
wiId <- insert recognitionsWorkflowInst
|
||||
insert_ WorkflowInstanceDescription
|
||||
{ workflowInstanceDescriptionInstance = wiId
|
||||
, workflowInstanceDescriptionLanguage = "de-de-formal"
|
||||
, workflowInstanceDescriptionTitle = "Anerkennungen"
|
||||
, workflowInstanceDescriptionDescription = Nothing
|
||||
}
|
||||
workflowInstanceScope = dbScope
|
||||
workflowInstanceName = workflowDefinitionName workflowDef
|
||||
workflowInstanceCategory = workflowDefinitionInstanceCategory workflowDef
|
||||
in insert WorkflowInstance{..}
|
||||
iforM_ iDescs $ \workflowInstanceDescriptionLanguage (workflowInstanceDescriptionTitle, workflowInstanceDescriptionDescription) ->
|
||||
let workflowInstanceDescriptionInstance = wiId
|
||||
in insert_ WorkflowInstanceDescription{..}
|
||||
|
||||
forM_ universeF $ \changelogItem -> do
|
||||
let ptn = "templates/i18n/changelog/" <> unpack (toPathPiece changelogItem) <> ".*"
|
||||
|
||||
2
testdata/workflows
vendored
2
testdata/workflows
vendored
@ -1 +1 @@
|
||||
Subproject commit ea616bce889da4c923bd2aa35d176f70f3a7ca8f
|
||||
Subproject commit 071c245fbdd7d409f83627dbd705ac0d10a22d4f
|
||||
Loading…
Reference in New Issue
Block a user