Skip to content

Commit

Permalink
Refactor backgrounds tasks for better visibility (#926)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbryzek authored Jun 6, 2024
1 parent b02516f commit a4a7a48
Show file tree
Hide file tree
Showing 61 changed files with 2,740 additions and 2,361 deletions.
10 changes: 5 additions & 5 deletions .apibuilder/.tracked_files
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ apicollective:
apibuilder-api:
anorm_2_8_parsers:
- api/app/generated/ApicollectiveApibuilderApiV0Conversions.scala
- api/app/generated/ApicollectiveApibuilderApiV0Parsers.scala
play_2_8_client:
- generated/app/ApicollectiveApibuilderApiV0Client.scala
play_2_x_routes:
Expand All @@ -14,28 +13,29 @@ apicollective:
apibuilder-common:
anorm_2_8_parsers:
- api/app/generated/ApicollectiveApibuilderCommonV0Conversions.scala
- api/app/generated/ApicollectiveApibuilderCommonV0Parsers.scala
play_2_x_json:
- generated/app/ApicollectiveApibuilderCommonV0Models.scala
apibuilder-generator:
anorm_2_8_parsers:
- api/app/generated/ApicollectiveApibuilderGeneratorV0Conversions.scala
- api/app/generated/ApicollectiveApibuilderGeneratorV0Parsers.scala
play_2_8_client:
- generated/app/ApicollectiveApibuilderGeneratorV0Client.scala
play_2_8_mock_client:
- generated/app/ApicollectiveApibuilderGeneratorV0MockClient.scala
apibuilder-internal:
anorm_2_8_parsers:
- api/app/generated/ApicollectiveApibuilderInternalV0Conversions.scala
- api/app/generated/ApicollectiveApibuilderInternalV0Parsers.scala
play_2_x_json:
- generated/app/ApicollectiveApibuilderInternalV0Models.scala
apibuilder-spec:
anorm_2_8_parsers:
- api/app/generated/ApicollectiveApibuilderSpecV0Conversions.scala
- api/app/generated/ApicollectiveApibuilderSpecV0Parsers.scala
play_2_8_client:
- generated/app/ApicollectiveApibuilderSpecV0Client.scala
play_2_8_mock_client:
- generated/app/ApicollectiveApibuilderSpecV0MockClient.scala
apibuilder-task:
play_2_8_client:
- generated/app/ApicollectiveApibuilderTaskV0Client.scala
play_2_8_mock_client:
- generated/app/ApicollectiveApibuilderTaskV0MockClient.scala
7 changes: 4 additions & 3 deletions .apibuilder/config
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ code:
play_2_8_client: generated/app
play_2_8_mock_client: generated/app
anorm_2_8_parsers: api/app/generated
apibuilder-internal:
apibuilder-task:
version: latest
generators:
play_2_x_json: generated/app
anorm_2_8_parsers: api/app/generated
play_2_8_client: generated/app
play_2_8_mock_client: generated/app

11 changes: 6 additions & 5 deletions api/app/actors/Bindings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import play.api.libs.concurrent.AkkaGuiceSupport

class ActorsModule extends AbstractModule with AkkaGuiceSupport {
override def configure = {
bindActor[MainActor]("main-actor")
bindActor[GeneratorServiceActor]("generator-service-actor")
bindActor[EmailActor]("email-actor")
bindActor[TaskActor]("task-actor")
bindActor[UserActor]("user-actor")
bindActor[PeriodicActor]("PeriodicActor")
bindActor[TaskDispatchActor](
"TaskDispatchActor",
_.withDispatcher("task-context-dispatcher")
)
bindActorFactory[TaskActor, actors.TaskActor.Factory]
}
}
131 changes: 0 additions & 131 deletions api/app/actors/EmailActor.scala

This file was deleted.

39 changes: 11 additions & 28 deletions api/app/actors/Emails.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package actors

import io.apibuilder.api.v0.models._
import db.{ApplicationsDao, Authorization, MembershipsDao, SubscriptionsDao}
import javax.inject.{Inject, Singleton}
import io.apibuilder.api.v0.models._
import lib._
import play.api.{Logger, Logging}
import play.api.Logging

import javax.inject.{Inject, Singleton}

object Emails {

Expand All @@ -29,7 +30,6 @@ object Emails {

@Singleton
class Emails @Inject() (
appConfig: AppConfig,
email: EmailUtil,
applicationsDao: ApplicationsDao,
membershipsDao: MembershipsDao,
Expand All @@ -46,11 +46,13 @@ class Emails @Inject() (
implicit filter: Subscription => Boolean = { _ => true }
): Unit = {
eachSubscription(context, org, publication, { subscription =>
email.sendHtml(
to = Person(subscription.user),
subject = subject,
body = body
)
if (filter(subscription)) {
email.sendHtml(
to = Person(subscription.user),
subject = subject,
body = body
)
}
})
}

Expand Down Expand Up @@ -108,23 +110,4 @@ class Emails @Inject() (
}
}

def sendErrors(
subject: String,
errors: Seq[String]
): Unit = {
errors match {
case Nil => {}
case _ => {
val body = views.html.emails.errors(errors).toString
appConfig.sendErrorsTo.foreach { emailAddress =>
email.sendHtml(
to = Person(emailAddress),
subject = subject,
body = body
)
}
}
}
}

}
50 changes: 0 additions & 50 deletions api/app/actors/GeneratorServiceActor.scala

This file was deleted.

Loading

0 comments on commit a4a7a48

Please sign in to comment.