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
|
||||||
import Utils.Workflow.Lint
|
import Utils.Workflow.Lint
|
||||||
|
|
||||||
import System.Directory (getModificationTime)
|
import System.Directory (getModificationTime, doesFileExist)
|
||||||
import System.FilePath.Glob (glob)
|
import System.FilePath.Glob (glob)
|
||||||
|
|
||||||
import System.IO (hPutStrLn)
|
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 :: FilePath
|
||||||
testdataDir = "testdata"
|
testdataDir = "testdata"
|
||||||
@ -1397,82 +1412,41 @@ fillDb = do
|
|||||||
|
|
||||||
liftIO . LBS.writeFile (testdataDir </> "bigAlloc_ordinal.csv") $ Csv.encode ordinalPriorities
|
liftIO . LBS.writeFile (testdataDir </> "bigAlloc_ordinal.csv") $ Csv.encode ordinalPriorities
|
||||||
|
|
||||||
let displayLinterIssue :: MonadIO m => WorkflowGraphLinterIssue -> m ()
|
whenM (liftIO . doesFileExist $ testdataDir </> "workflows" </> "_index.yaml") $ do
|
||||||
displayLinterIssue = liftIO . hPutStrLn stderr . displayException
|
let displayLinterIssue :: MonadIO m => WorkflowGraphLinterIssue -> m ()
|
||||||
|
displayLinterIssue = liftIO . hPutStrLn stderr . displayException
|
||||||
|
|
||||||
handleSql displayLinterIssue $ do
|
wfIndex <- Yaml.decodeFileThrow @_ @(Map WorkflowDefinitionName WorkflowIndexItem) $ testdataDir </> "workflows" </> "_index.yaml"
|
||||||
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."
|
|
||||||
}
|
|
||||||
|
|
||||||
handleSql displayLinterIssue $ do
|
iforM_ wfIndex $ \wiName WorkflowIndexItem{..} -> handleSql displayLinterIssue $ do
|
||||||
graph <- Yaml.decodeFileThrow $ testdataDir </> "workflows" </> "recognitions-ifi.yaml"
|
graph <- Yaml.decodeFileThrow $ testdataDir </> "workflows" </> wiiGraphFile
|
||||||
for_ (lintWorkflowGraph graph) $ mapM_ throwM
|
for_ (lintWorkflowGraph graph) $ mapM_ throwM
|
||||||
workflowDefinitionGraph <- insertSharedWorkflowGraph graph
|
workflowDefinitionGraph <- insertSharedWorkflowGraph graph
|
||||||
let
|
let workflowDef = WorkflowDefinition{..}
|
||||||
recognitionsWorkflowDef = WorkflowDefinition{..}
|
where workflowDefinitionInstanceCategory = wiiCategory
|
||||||
where workflowDefinitionInstanceCategory = Just "recognitions-ifi"
|
workflowDefinitionName = wiName
|
||||||
workflowDefinitionName = "recognitions-ifi"
|
workflowDefinitionScope = wiiDefinitionScope
|
||||||
workflowDefinitionScope = WSSchool'
|
wdId <- insert workflowDef
|
||||||
wdId <- insert recognitionsWorkflowDef
|
let descs = maybe Map.empty (\I18n{..} -> Map.insert (fromMaybe (NonEmpty.head appLanguages) i18nFallbackLang) i18nFallback i18nTranslations) wiiDefinitionDescription
|
||||||
insert_ WorkflowDefinitionDescription
|
iDescs = maybe Map.empty (\I18n{..} -> Map.insert (fromMaybe (NonEmpty.head appLanguages) i18nFallbackLang) i18nFallback i18nTranslations) wiiInstanceDescription
|
||||||
{ workflowDefinitionDescriptionDefinition = wdId
|
iforM_ descs $ \workflowDefinitionDescriptionLanguage (workflowDefinitionDescriptionTitle, workflowDefinitionDescriptionDescription) ->
|
||||||
, workflowDefinitionDescriptionLanguage = "de-de-formal"
|
let workflowDefinitionDescriptionDefinition = wdId
|
||||||
, workflowDefinitionDescriptionTitle = "Anerkennungen"
|
in insert_ WorkflowDefinitionDescription{..}
|
||||||
, workflowDefinitionDescriptionDescription = Just "Erlaubt Anerkennungen von Leistungen in Uni2work zu verwalten"
|
iforM_ iDescs $ \workflowDefinitionInstanceDescriptionLanguage (workflowDefinitionInstanceDescriptionTitle, workflowDefinitionInstanceDescriptionDescription) ->
|
||||||
}
|
let workflowDefinitionInstanceDescriptionDefinition = wdId
|
||||||
insert_ WorkflowDefinitionInstanceDescription
|
in insert_ WorkflowDefinitionInstanceDescription{..}
|
||||||
{ workflowDefinitionInstanceDescriptionDefinition = wdId
|
forM_ wiiInstances $ \rScope -> do
|
||||||
, workflowDefinitionInstanceDescriptionLanguage = "de-de-formal"
|
dbScope <- fmap (view _DBWorkflowScope) . maybeT (error $ "Could not resolve scope: " <> show rScope) $ fromRouteWorkflowScope rScope
|
||||||
, workflowDefinitionInstanceDescriptionTitle = "Anerekennungen"
|
wiId <-
|
||||||
, workflowDefinitionInstanceDescriptionDescription = Nothing
|
let workflowInstanceDefinition = Just wdId
|
||||||
}
|
|
||||||
let
|
|
||||||
recognitionsWorkflowInst = WorkflowInstance{..}
|
|
||||||
where workflowInstanceDefinition = Just wdId
|
|
||||||
workflowInstanceGraph = workflowDefinitionGraph
|
workflowInstanceGraph = workflowDefinitionGraph
|
||||||
workflowInstanceScope = WSSchool $ unSchoolKey ifi
|
workflowInstanceScope = dbScope
|
||||||
workflowInstanceName = workflowDefinitionName recognitionsWorkflowDef
|
workflowInstanceName = workflowDefinitionName workflowDef
|
||||||
workflowInstanceCategory = workflowDefinitionInstanceCategory recognitionsWorkflowDef
|
workflowInstanceCategory = workflowDefinitionInstanceCategory workflowDef
|
||||||
wiId <- insert recognitionsWorkflowInst
|
in insert WorkflowInstance{..}
|
||||||
insert_ WorkflowInstanceDescription
|
iforM_ iDescs $ \workflowInstanceDescriptionLanguage (workflowInstanceDescriptionTitle, workflowInstanceDescriptionDescription) ->
|
||||||
{ workflowInstanceDescriptionInstance = wiId
|
let workflowInstanceDescriptionInstance = wiId
|
||||||
, workflowInstanceDescriptionLanguage = "de-de-formal"
|
in insert_ WorkflowInstanceDescription{..}
|
||||||
, workflowInstanceDescriptionTitle = "Anerkennungen"
|
|
||||||
, workflowInstanceDescriptionDescription = Nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
forM_ universeF $ \changelogItem -> do
|
forM_ universeF $ \changelogItem -> do
|
||||||
let ptn = "templates/i18n/changelog/" <> unpack (toPathPiece changelogItem) <> ".*"
|
let ptn = "templates/i18n/changelog/" <> unpack (toPathPiece changelogItem) <> ".*"
|
||||||
|
|||||||
2
testdata/workflows
vendored
2
testdata/workflows
vendored
@ -1 +1 @@
|
|||||||
Subproject commit ea616bce889da4c923bd2aa35d176f70f3a7ca8f
|
Subproject commit 071c245fbdd7d409f83627dbd705ac0d10a22d4f
|
||||||
Reference in New Issue
Block a user