Fixes related to addons

- Fix applying new-items from addon results
- Notify joex when a scheduled addon is updated
This commit is contained in:
eikek 2022-05-23 23:28:54 +02:00
parent 2dedb6d7a1
commit 6c57077d68
3 changed files with 20 additions and 16 deletions

View File

@ -25,7 +25,7 @@ object AddonOutput {
val empty: AddonOutput = AddonOutput()
def combine(a: AddonOutput, b: AddonOutput): AddonOutput =
AddonOutput(a.commands ++ b.commands, a.files ++ b.files)
AddonOutput(a.commands ++ b.commands, a.files ++ b.files, a.newItems ++ b.newItems)
implicit val addonResultMonoid: Monoid[AddonOutput] =
Monoid.instance(empty, combine)

View File

@ -50,10 +50,11 @@ final private[joex] class AddonPostProcess[F[_]: Sync: Files](
outputDir: Path
): F[Unit] =
for {
_ <- logger.info("Applying addon output")
_ <- logger.info(s"Applying addon output commands (${output.commands.size})")
_ <- cmdRunner.runAll(collective, output.commands)
_ <- logger.debug("Applying changes from files")
_ <- logger.debug(s"Applying changes from files (${output.files.size})")
_ <- output.files.traverse_(updateOne(logger, collective, outputDir))
_ <- logger.debug(s"Applying new items (${output.newItems.size})")
_ <- output.newItems.traverse_(submitNewItem(logger, collective, outputDir))
} yield ()
@ -63,7 +64,7 @@ final private[joex] class AddonPostProcess[F[_]: Sync: Files](
outputDir: Path
)(newItem: NewItem): F[Unit] =
for {
_ <- logger.info(s"Submit new item with ${newItem.files.size} files")
_ <- logger.debug(s"Submit new item with ${newItem.files.size} files")
files <- newItem.resolveFiles[F](logger, outputDir)
collLang <- store.transact(RCollective.findLanguage(collective))
uploaded <- files.traverse(file =>

View File

@ -223,20 +223,23 @@ object OAddons {
upsert.flatTap { runConfigId =>
runConfig.schedule match {
case Some(timer) =>
userTasks.updateTask(
UserTaskScope.collective(collective),
s"Addon task ${runConfig.name}".some,
UserTask(
runConfigId,
scheduledAddonTaskName,
true,
timer,
s"Running scheduled addon task ${runConfig.name}".some,
ScheduledAddonTaskArgs(collective, runConfigId)
userTasks
.updateTask(
UserTaskScope.collective(collective),
s"Addon task ${runConfig.name}".some,
UserTask(
runConfigId,
scheduledAddonTaskName,
true,
timer,
s"Running scheduled addon task ${runConfig.name}".some,
ScheduledAddonTaskArgs(collective, runConfigId)
)
)
)
.flatTap(_ => joex.notifyPeriodicTasks)
case None =>
userTasks.deleteTask(UserTaskScope.collective(collective), runConfigId)
userTasks
.deleteTask(UserTaskScope.collective(collective), runConfigId)
}
}
)