Merge pull request #1566 from eikek/fix-addon-newitem

Fixes related to addons
This commit is contained in:
mergify[bot] 2022-05-23 21:45:20 +00:00 committed by GitHub
commit 497b6ff98b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 16 deletions

View File

@ -25,7 +25,7 @@ object AddonOutput {
val empty: AddonOutput = AddonOutput() val empty: AddonOutput = AddonOutput()
def combine(a: AddonOutput, b: 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] = implicit val addonResultMonoid: Monoid[AddonOutput] =
Monoid.instance(empty, combine) Monoid.instance(empty, combine)

View File

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

View File

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