Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace private[this] with private in prep for scala3 #935

Merged
merged 1 commit into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/app/actors/ErrorHandler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ trait ErrorHandler {
logger.error(msg(s"got an unhandled message: $description"))
}

private[this] def msg(value: String) = {
private def msg(value: String) = {
s"${getClass.getName}: $value"
}

Expand Down
10 changes: 5 additions & 5 deletions api/app/actors/ScheduleTasksActor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class ScheduleTasksActor @Inject()(
env: Environment
) extends Actor with ActorLogging with ErrorHandler {

private[this] implicit val ec: ExecutionContext = context.system.dispatchers.lookup("schedule-tasks-actor-context")
private implicit val ec: ExecutionContext = context.system.dispatchers.lookup("schedule-tasks-actor-context")

private[this] case class UpsertTask(typ: TaskType)
private case class UpsertTask(typ: TaskType)

private[this] def schedule(
private def schedule(
taskType: TaskType,
interval: FiniteDuration
)(implicit
Expand All @@ -31,14 +31,14 @@ class ScheduleTasksActor @Inject()(
context.system.scheduler.scheduleWithFixedDelay(finalInitial, interval, self, UpsertTask(taskType))
}

private[this] def scheduleOnce(taskType: TaskType): Unit = {
private def scheduleOnce(taskType: TaskType): Unit = {
context.system.scheduler.scheduleOnce(FiniteDuration(10, SECONDS)) {
UpsertTask(taskType)
}
}


private[this] val cancellables: Seq[Cancellable] = {
private val cancellables: Seq[Cancellable] = {
import TaskType._
scheduleOnce(ScheduleMigrateVersions)
Seq(
Expand Down
14 changes: 7 additions & 7 deletions api/app/actors/TaskDispatchActor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ class TaskDispatchActor @Inject() (
factory: TaskActor.Factory,
companion: TaskDispatchActorCompanion
) extends Actor with ActorLogging with ErrorHandler with InjectedActorSupport {
private[this] val ec: ExecutionContext = context.system.dispatchers.lookup("task-context")
private[this] case object Process
private val ec: ExecutionContext = context.system.dispatchers.lookup("task-context")
private case object Process

private[this] val actors = scala.collection.mutable.Map[TaskType, ActorRef]()
private val actors = scala.collection.mutable.Map[TaskType, ActorRef]()

private[this] def schedule(message: Any, interval: FiniteDuration): Cancellable = {
private def schedule(message: Any, interval: FiniteDuration): Cancellable = {
context.system.scheduler.scheduleWithFixedDelay(FiniteDuration(1, SECONDS), interval, self, message)(ec)
}

private[this] val cancellables: Seq[Cancellable] = {
private val cancellables: Seq[Cancellable] = {
Seq(
schedule(Process, FiniteDuration(2, SECONDS))
)
Expand All @@ -39,13 +39,13 @@ class TaskDispatchActor @Inject() (
case other => logUnhandledMessage(other)
}

private[this] def process(): Unit = {
private def process(): Unit = {
companion.typesWithWork.foreach { typ =>
upsertActor(typ) ! TaskActor.Process
}
}

private[this] def upsertActor(typ: TaskType): ActorRef = {
private def upsertActor(typ: TaskType): ActorRef = {
actors.getOrElse(
typ, {
val name = s"task$typ"
Expand Down
4 changes: 2 additions & 2 deletions api/app/controllers/ApiBuilderController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ trait ApiBuilderController extends BaseController {
}
}

private[this] def withRole(org: Organization, user: User, roles: Seq[MembershipRole])(f: => Result): Result = {
private def withRole(org: Organization, user: User, roles: Seq[MembershipRole])(f: => Result): Result = {
val actualRoles = membershipsDao.findByOrganizationAndUserAndRoles(
Authorization.All, org, user, roles
).map(_.role)
Expand All @@ -77,7 +77,7 @@ trait ApiBuilderController extends BaseController {
}
}

private[this] def jsonError(message: String): JsValue = {
private def jsonError(message: String): JsValue = {
Json.toJson(
Validation.error(
message
Expand Down
10 changes: 5 additions & 5 deletions api/app/controllers/Code.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Code @Inject() (
}
}

private[this] implicit val ec: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global
private implicit val ec: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global

def getByGeneratorKey(
orgKey: String,
Expand Down Expand Up @@ -211,22 +211,22 @@ class Code @Inject() (
}
}

private[this] def withCodeForm(body: JsValue)(f: CodeForm => Future[Result]) = {
private def withCodeForm(body: JsValue)(f: CodeForm => Future[Result]) = {
body.validate[CodeForm] match {
case e: JsError => Future.successful(Conflict(Json.toJson(Validation.invalidJson(e))))
case s: JsSuccess[CodeForm] => f(s.get)
}
}

private[this] def conflict(message: String): Result = {
private def conflict(message: String): Result = {
conflict(Seq(message))
}

private[this] def conflict(messages: Seq[String]): Result = {
private def conflict(messages: Seq[String]): Result = {
Conflict(Json.toJson(Validation.errors(messages)))
}

private[this] def recordInvocation(params: CodeParams, generatorKey: String): Unit = {
private def recordInvocation(params: CodeParams, generatorKey: String): Unit = {
generatorInvocationsDao.insert(Constants.DefaultUserGuid, GeneratorInvocationForm(
key = generatorKey,
organizationKey = Some(params.orgKey),
Expand Down
2 changes: 1 addition & 1 deletion api/app/controllers/Healthchecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Healthchecks @Inject() (
organizationsDao: OrganizationsDao,
) extends ApiBuilderController {

private[this] val Result = Json.toJson(Map("status" -> "healthy"))
private val Result = Json.toJson(Map("status" -> "healthy"))

def getHealthcheck(): Action[AnyContent] = Action { _ =>
organizationsDao.findAll(Authorization.PublicOnly, limit = 1).headOption
Expand Down
2 changes: 1 addition & 1 deletion api/app/controllers/Organizations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class Organizations @Inject() (
}
}

private[this] def withAttribute(
private def withAttribute(
name: String
) (
f: Attribute => Result
Expand Down
10 changes: 5 additions & 5 deletions api/app/controllers/Users.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class Users @Inject() (

import scala.concurrent.ExecutionContext.Implicits.global

private[this] case class UserAuthenticationForm(email: String, password: String)
private[this] implicit val userAuthenticationFormReads: Reads[UserAuthenticationForm] = Json.reads[UserAuthenticationForm]
private case class UserAuthenticationForm(email: String, password: String)
private implicit val userAuthenticationFormReads: Reads[UserAuthenticationForm] = Json.reads[UserAuthenticationForm]

private[this] case class GithubAuthenticationForm(token: String)
private[this] implicit val githubAuthenticationFormReads: Reads[GithubAuthenticationForm] = Json.reads[GithubAuthenticationForm]
private case class GithubAuthenticationForm(token: String)
private implicit val githubAuthenticationFormReads: Reads[GithubAuthenticationForm] = Json.reads[GithubAuthenticationForm]

def get(
guid: Option[UUID],
Expand Down Expand Up @@ -188,7 +188,7 @@ class Users @Inject() (
}
}

private[this] def requireSystemUser(user: User): Unit = {
private def requireSystemUser(user: User): Unit = {
require(
user.guid == UsersDao.AdminUserGuid,
"Action restricted to the system admin user"
Expand Down
2 changes: 1 addition & 1 deletion api/app/controllers/Validations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Validations @Inject() (
databaseServiceFetcher: DatabaseServiceFetcher
) extends ApiBuilderController {

private[this] val config = ServiceConfiguration(
private val config = ServiceConfiguration(
orgKey = "tmp",
orgNamespace = "tmp.validations",
version = "0.0.1-dev"
Expand Down
6 changes: 3 additions & 3 deletions api/app/controllers/Versions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Versions @Inject() (
versionValidator: VersionValidator,
) extends ApiBuilderController {

private[this] val DefaultVisibility = Visibility.Organization
private val DefaultVisibility = Visibility.Organization

def getByApplicationKey(orgKey: String, applicationKey: String, limit: Long = 25, offset: Long = 0) = Anonymous { request =>
val versions = applicationsDao.findByOrganizationKeyAndApplicationKey(request.authorization, orgKey, applicationKey).map { application =>
Expand Down Expand Up @@ -209,7 +209,7 @@ class Versions @Inject() (
}
}

private[this] def upsertVersion(
private def upsertVersion(
user: User,
org: Organization,
versionName: String,
Expand Down Expand Up @@ -256,7 +256,7 @@ class Versions @Inject() (
}
}

private[this] def toServiceConfiguration(
private def toServiceConfiguration(
org: Organization,
version: String
) = ServiceConfiguration(
Expand Down
16 changes: 8 additions & 8 deletions api/app/db/ApplicationsDao.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class ApplicationsDao @Inject() (
tasksDao: InternalTasksDao,
) {

private[this] val dbHelpers = DbHelpers(db, "applications")
private val dbHelpers = DbHelpers(db, "applications")

private[this] val BaseQuery = Query(
private val BaseQuery = Query(
s"""
select applications.guid, applications.name, applications.key, applications.description, applications.visibility,
${AuditsDao.query("applications")},
Expand All @@ -42,15 +42,15 @@ class ApplicationsDao @Inject() (
"""
)

private[this] val InsertQuery =
private val InsertQuery =
"""
insert into applications
(guid, organization_guid, name, description, key, visibility, created_by_guid, updated_by_guid)
values
({guid}::uuid, {organization_guid}::uuid, {name}, {description}, {key}, {visibility}, {created_by_guid}::uuid, {created_by_guid}::uuid)
"""

private[this] val UpdateQuery =
private val UpdateQuery =
"""
update applications
set name = {name},
Expand All @@ -60,23 +60,23 @@ class ApplicationsDao @Inject() (
where guid = {guid}::uuid
"""

private[this] val InsertMoveQuery =
private val InsertMoveQuery =
"""
insert into application_moves
(guid, application_guid, from_organization_guid, to_organization_guid, created_by_guid)
values
({guid}::uuid, {application_guid}::uuid, {from_organization_guid}::uuid, {to_organization_guid}::uuid, {created_by_guid}::uuid)
"""

private[this] val UpdateOrganizationQuery =
private val UpdateOrganizationQuery =
"""
update applications
set organization_guid = {org_guid}::uuid,
updated_by_guid = {updated_by_guid}::uuid
where guid = {guid}::uuid
"""

private[this] val UpdateVisibilityQuery =
private val UpdateVisibilityQuery =
"""
update applications
set visibility = {visibility},
Expand Down Expand Up @@ -355,7 +355,7 @@ class ApplicationsDao @Inject() (
}
}

private[this] def withTasks(
private def withTasks(
guid: UUID,
f: java.sql.Connection => Unit
): Unit = {
Expand Down
6 changes: 3 additions & 3 deletions api/app/db/AttributesDao.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ class AttributesDao @Inject() (
@NamedDatabase("default") db: Database
) {

private[this] val dbHelpers = DbHelpers(db, "attributes")
private val dbHelpers = DbHelpers(db, "attributes")

private[this] val BaseQuery = Query(s"""
private val BaseQuery = Query(s"""
select attributes.guid,
attributes.name,
attributes.description,
${AuditsDao.query("attributes")}
from attributes
""")

private[this] val InsertQuery = """
private val InsertQuery = """
insert into attributes
(guid, name, description, created_by_guid, updated_by_guid)
values
Expand Down
4 changes: 2 additions & 2 deletions api/app/db/Authorization.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ sealed trait Authorization {

object Authorization {

private[this] val OrgsByUserQuery =
private val OrgsByUserQuery =
s"select organization_guid from memberships where memberships.deleted_at is null and memberships.user_guid = {authorization_user_guid}::uuid"

private[this] val PublicApplicationsQuery = s"%s.visibility = '${Visibility.Public.toString}'"
private val PublicApplicationsQuery = s"%s.visibility = '${Visibility.Public.toString}'"

case object PublicOnly extends Authorization {

Expand Down
6 changes: 3 additions & 3 deletions api/app/db/ChangesDao.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ChangesDao @Inject() (
@NamedDatabase("default") db: Database
) {

private[this] val BaseQuery = Query(
private val BaseQuery = Query(
s"""
select changes.guid,
changes.type,
Expand All @@ -48,7 +48,7 @@ class ChangesDao @Inject() (
join users on users.guid = changes.changed_by_guid
""")

private[this] val InsertQuery =
private val InsertQuery =
"""
insert into changes
(guid, application_guid, from_version_guid, to_version_guid, type, description, is_material, changed_at, changed_by_guid, created_by_guid)
Expand Down Expand Up @@ -158,7 +158,7 @@ class ChangesDao @Inject() (
}
}

private[this] def parser(): RowParser[io.apibuilder.api.v0.models.Change] = {
private def parser(): RowParser[io.apibuilder.api.v0.models.Change] = {
SqlParser.get[UUID]("guid") ~
io.apibuilder.common.v0.anorm.parsers.Reference.parserWithPrefix("organization") ~
io.apibuilder.common.v0.anorm.parsers.Reference.parserWithPrefix("application") ~
Expand Down
4 changes: 2 additions & 2 deletions api/app/db/DbHelpers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ case class DbHelpers(
tableName: String
) {

private[this] val softDeleteQueryById = Query(s"""
private val softDeleteQueryById = Query(s"""
update $tableName
set deleted_by_guid = {deleted_by_guid}::uuid, deleted_at = now()
where id = {id}
and deleted_at is null
""")

private[this] val softDeleteQueryByGuid = Query(s"""
private val softDeleteQueryByGuid = Query(s"""
update $tableName
set deleted_by_guid = {deleted_by_guid}::uuid, deleted_at = now()
where guid = {guid}::uuid
Expand Down
6 changes: 3 additions & 3 deletions api/app/db/EmailVerificationConfirmationsDao.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ private[db] class EmailVerificationConfirmationsDao @Inject() (
@NamedDatabase("default") db: Database
) {

private[this] val BaseQuery = Query(
private val BaseQuery = Query(
"""
select email_verification_confirmations.guid,
email_verification_confirmations.email_verification_guid,
email_verification_confirmations.created_at
from email_verification_confirmations
""")

private[this] val InsertQuery =
private val InsertQuery =
"""
insert into email_verification_confirmations
(guid, email_verification_guid, created_by_guid)
Expand Down Expand Up @@ -77,7 +77,7 @@ private[db] class EmailVerificationConfirmationsDao @Inject() (
}
}

private[this] def parser(): RowParser[EmailVerificationConfirmation] = {
private def parser(): RowParser[EmailVerificationConfirmation] = {
SqlParser.get[UUID]("guid") ~
SqlParser.get[UUID]("email_verification_guid") ~
SqlParser.get[DateTime]("created_at") map {
Expand Down
Loading
Loading