Skip to content

Commit

Permalink
Merge pull request #189 from scala-steward/update/scalafmt-core-3.8.2
Browse files Browse the repository at this point in the history
Update scalafmt-core to 3.8.2
  • Loading branch information
mergify[bot] authored Jun 25, 2024
2 parents 537a132 + 41dbb10 commit 442b350
Show file tree
Hide file tree
Showing 38 changed files with 291 additions and 186 deletions.
4 changes: 3 additions & 1 deletion .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# more scalafmt
038c8c5a2b9dc039b97c3c8e34337c165da0052b
# initial scalafmt
4e224a6ff898ddf989d9a69b95ea6349f605ec90
4e224a6ff898ddf989d9a69b95ea6349f605ec90
# Scala Steward: Reformat with scalafmt 3.8.2
c980f5875ba856d02ca8da6162f54f44793dcd16
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.7.17
version = 3.8.2
runner.dialect = Scala213Source3
maxColumn = 100
indent.defnSite = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,20 @@ import akka.http.scaladsl.server.Directives
import akka.http.scaladsl.util.FastFuture
import com.advancedtelematic.director.{Settings, VersionInfo}
import com.advancedtelematic.libats.http.{BootApp, BootAppDatabaseConfig, BootAppDefaultConfig}
import com.advancedtelematic.libats.messaging.{BusListenerMetrics, MessageBus, MessageBusPublisher, MessageListenerSupport, MetricsBusMonitor}
import com.advancedtelematic.libats.messaging_datatype.Messages.{DeleteDeviceRequest, DeviceEventMessage, DeviceSeen, DeviceUpdateEvent, EcuReplacement}
import com.advancedtelematic.libats.messaging.{
BusListenerMetrics,
MessageBus,
MessageBusPublisher,
MessageListenerSupport,
MetricsBusMonitor
}
import com.advancedtelematic.libats.messaging_datatype.Messages.{
DeleteDeviceRequest,
DeviceEventMessage,
DeviceSeen,
DeviceUpdateEvent,
EcuReplacement
}
import com.advancedtelematic.libats.slick.db.{BootMigrations, DatabaseSupport}
import com.advancedtelematic.libats.slick.monitoring.DbHealthResource
import com.advancedtelematic.libtuf_server.data.Messages.TufTargetAdded
Expand All @@ -18,7 +30,11 @@ import com.typesafe.config.Config
import com.advancedtelematic.libats.http.VersionDirectives.*
import com.advancedtelematic.libats.messaging.metrics.MonitoredBusListenerSupport
import com.advancedtelematic.metrics.prometheus.PrometheusMetricsSupport
import com.advancedtelematic.director.deviceregistry.daemon.{DeviceEventListener, DeviceUpdateEventListener, EcuReplacementListener}
import com.advancedtelematic.director.deviceregistry.daemon.{
DeviceEventListener,
DeviceUpdateEventListener,
EcuReplacementListener
}
import org.bouncycastle.jce.provider.BouncyCastleProvider

import java.security.Security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,8 @@ protected class AssignmentsRepository()(implicit val db: Database, val ec: Execu
else
DBIO
.seq(
Schema.processedAssignments ++= assignments.map(
_.toProcessedAssignment(successful = true, canceled = true)
),
Schema.processedAssignments ++= assignments
.map(_.toProcessedAssignment(successful = true, canceled = true)),
assignmentQuery.delete,
deviceRepository.setMetadataOutdatedAction(Set(deviceId), outdated = true)
)
Expand Down
112 changes: 37 additions & 75 deletions src/main/scala/com/advancedtelematic/director/db/Schema.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,10 @@ object Schema {

def pk = primaryKey("devices_pk", id)

override def * = (
namespace,
id,
primaryEcu,
generatedMetadataOutdated,
deleted
) <> ((Device.apply _).tupled, Device.unapply)
override def * = (namespace, id, primaryEcu, generatedMetadataOutdated, deleted) <> (
(Device.apply _).tupled,
Device.unapply
)

}

Expand All @@ -77,14 +74,10 @@ object Schema {

def primKey = primaryKey("ecus_pk", (deviceId, ecuSerial))

override def * = (
ecuSerial,
deviceId,
namespace,
hardwareId,
publicKey,
installedTarget
) <> ((Ecu.apply _).tupled, Ecu.unapply)
override def * = (ecuSerial, deviceId, namespace, hardwareId, publicKey, installedTarget) <> (
(Ecu.apply _).tupled,
Ecu.unapply
)

}

Expand All @@ -106,16 +99,11 @@ object Schema {

def primKey = primaryKey("ecu_targets_pk", id)

override def * = (
namespace,
id,
filename,
length,
checksum,
sha256,
uri,
userDefinedCustom
) <> ((EcuTarget.apply _).tupled, EcuTarget.unapply)
override def * =
(namespace, id, filename, length, checksum, sha256, uri, userDefinedCustom) <> (
(EcuTarget.apply _).tupled,
EcuTarget.unapply
)

}

Expand All @@ -134,16 +122,10 @@ object Schema {

def primKey = primaryKey("offline_targets_pk", (repoId, name, version))

override def * = (
repoId,
role,
name,
checksum,
length,
version,
expires,
content
) <> ((DbAdminRole.apply _).tupled, DbAdminRole.unapply)
override def * = (repoId, role, name, checksum, length, version, expires, content) <> (
(DbAdminRole.apply _).tupled,
DbAdminRole.unapply
)

}

Expand All @@ -161,15 +143,10 @@ object Schema {

def primKey = primaryKey("device_roles_pk", (role, version, device))

override def * = (
role,
device,
checksum,
length,
version,
expires,
content
) <> ((DbDeviceRole.apply _).tupled, DbDeviceRole.unapply)
override def * = (role, device, checksum, length, version, expires, content) <> (
(DbDeviceRole.apply _).tupled,
DbDeviceRole.unapply
)

}

Expand All @@ -184,15 +161,10 @@ object Schema {
def createdAt = column[Instant]("created_at")(javaInstantMapping)
def inFlight = column[Boolean]("in_flight")

def * = (
namespace,
deviceId,
ecuId,
ecuTargetId,
correlationId,
inFlight,
createdAt
) <> ((Assignment.apply _).tupled, Assignment.unapply)
def * = (namespace, deviceId, ecuId, ecuTargetId, correlationId, inFlight, createdAt) <> (
(Assignment.apply _).tupled,
Assignment.unapply
)

def pk = primaryKey("assignments_pk", (deviceId, ecuId))
}
Expand Down Expand Up @@ -233,13 +205,10 @@ object Schema {
def toTarget = column[EcuTargetId]("to_target_id")
def fromTarget = column[Option[EcuTargetId]]("from_target_id")

def * = (
namespace,
id,
hardwareId,
fromTarget,
toTarget
) <> ((HardwareUpdate.apply _).tupled, HardwareUpdate.unapply)
def * = (namespace, id, hardwareId, fromTarget, toTarget) <> (
(HardwareUpdate.apply _).tupled,
HardwareUpdate.unapply
)

def pk = primaryKey("mtu_pk", (id, hardwareId))
}
Expand All @@ -264,13 +233,10 @@ object Schema {
def targetName = column[TargetName]("target_name")
def deleted = column[Boolean]("deleted")

override def * = (
id,
namespace,
deviceId,
ecuId,
targetName
) <> ((AutoUpdateDefinition.apply _).tupled, AutoUpdateDefinition.unapply)
override def * = (id, namespace, deviceId, ecuId, targetName) <> (
(AutoUpdateDefinition.apply _).tupled,
AutoUpdateDefinition.unapply
)

}

Expand Down Expand Up @@ -305,14 +271,10 @@ object Schema {

def pk = primaryKey("scheduled-updates-pk", id)

override def * = (
namespace,
id,
deviceId,
updateId,
scheduledAt,
status
) <> ((ScheduledUpdate.apply _).tupled, ScheduledUpdate.unapply)
override def * = (namespace, id, deviceId, updateId, scheduledAt, status) <> (
(ScheduledUpdate.apply _).tupled,
ScheduledUpdate.unapply
)

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ import com.advancedtelematic.director.deviceregistry.data.DeviceStatus.DeviceSta
import com.advancedtelematic.director.deviceregistry.data.Group.GroupId
import com.advancedtelematic.director.deviceregistry.data.GroupType.GroupType
import com.advancedtelematic.director.deviceregistry.data.*
import DbOps.{
deviceTableToSlickOrder,
PaginationResultOps
}
import DbOps.{deviceTableToSlickOrder, PaginationResultOps}
import GroupInfoRepository.groupInfos
import GroupMemberRepository.groupMembers
import SlickMappings.*
Expand Down Expand Up @@ -67,7 +64,9 @@ object DeviceRepository {
val dbIO = devices += dbDevice
dbIO
.handleIntegrityErrors(Errors.ConflictingDevice(device.deviceName.some, device.deviceId.some))
.andThen(GroupMemberRepository.addDeviceToDynamicGroups(ns, DeviceDB.toDevice(dbDevice), Map.empty))
.andThen(
GroupMemberRepository.addDeviceToDynamicGroups(ns, DeviceDB.toDevice(dbDevice), Map.empty)
)
.map(_ => uuid)
.transactionally
}
Expand All @@ -88,7 +87,10 @@ object DeviceRepository {
.filter(d => d.namespace === ns && d.id === uuid)
.result
.headOption
.flatMap(_.map(DeviceDB.toDevice(_)).fold[DBIO[Device]](DBIO.failed(Errors.MissingDevice))(DBIO.successful))
.flatMap(
_.map(DeviceDB.toDevice(_))
.fold[DBIO[Device]](DBIO.failed(Errors.MissingDevice))(DBIO.successful)
)

def filterExisting(ns: Namespace, deviceOemIds: Set[DeviceOemId]): DBIO[Seq[DeviceId]] =
devices
Expand Down Expand Up @@ -136,7 +138,10 @@ object DeviceRepository {
.filter(_.id === uuid)
.result
.headOption
.flatMap(_.map(DeviceDB.toDevice(_)).fold[DBIO[Device]](DBIO.failed(Errors.MissingDevice))(DBIO.successful))
.flatMap(
_.map(DeviceDB.toDevice(_))
.fold[DBIO[Device]](DBIO.failed(Errors.MissingDevice))(DBIO.successful)
)

def findByUuids(ns: Namespace, ids: Seq[DeviceId]): Query[DeviceTable, DeviceDB, Seq] =
devices.filter(d => (d.namespace === ns) && (d.id.inSet(ids)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,10 @@ object EventJournal {

def pk = primaryKey("indexed_event_pk", (deviceUuid, eventId))

def * = (
deviceUuid,
eventId,
eventType,
correlationId
).shaped <> (IndexedEvent.tupled, IndexedEvent.unapply)
def * = (deviceUuid, eventId, eventType, correlationId).shaped <> (
IndexedEvent.tupled,
IndexedEvent.unapply
)

}

Expand All @@ -97,12 +95,10 @@ object EventJournal {

def pk = primaryKey("indexed_event_pk", (deviceUuid, eventId))

def * = (
deviceUuid,
eventId,
eventType,
correlationId
).shaped <> (IndexedEvent.tupled, IndexedEvent.unapply)
def * = (deviceUuid, eventId, eventType, correlationId).shaped <> (
IndexedEvent.tupled,
IndexedEvent.unapply
)

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ import com.advancedtelematic.libats.slick.db.SlickUUIDKey.*
import com.advancedtelematic.libats.slick.db.SlickValidatedGeneric.validatedStringMapper
import com.advancedtelematic.director.deviceregistry.data
import com.advancedtelematic.director.deviceregistry.data.GroupType.GroupType
import DbOps.{
PaginationResultOps,
SortBySlickOrderedGroupConversion
}
import DbOps.{PaginationResultOps, SortBySlickOrderedGroupConversion}
import SlickMappings.*
import com.advancedtelematic.director.http.deviceregistry.Errors
import slick.jdbc.MySQLProfile.api.*
Expand All @@ -48,14 +45,10 @@ object GroupInfoRepository {
def createdAt = column[Instant]("created_at")(javaInstantMapping)
def updatedAt = column[Instant]("updated_at")(javaInstantMapping)

def * = (
id,
groupName,
namespace,
createdAt,
groupType,
expression
) <> ((Group.apply _).tupled, Group.unapply)
def * = (id, groupName, namespace, createdAt, groupType, expression) <> (
(Group.apply _).tupled,
Group.unapply
)

}
// scalastyle:on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ import com.advancedtelematic.libats.slick.db.SlickUUIDKey.*
import com.advancedtelematic.director.http.deviceregistry.Errors.MemberAlreadyExists
import com.advancedtelematic.director.deviceregistry.data.DataType.HibernationStatus
import com.advancedtelematic.director.deviceregistry.data.Group.GroupId
import com.advancedtelematic.director.deviceregistry.data.{Device, DeviceDB, GroupExpression, GroupExpressionAST, GroupType, TagId}
import com.advancedtelematic.director.deviceregistry.data.{
Device,
DeviceDB,
GroupExpression,
GroupExpressionAST,
GroupType,
TagId
}
import DbOps.PaginationResultOps
import com.advancedtelematic.director.http.deviceregistry.Errors
import slick.jdbc.{PositionedParameters, SetParameter}
Expand Down Expand Up @@ -152,7 +159,11 @@ object GroupMemberRepository {
_ <- GroupInfoRepository.updateSmartGroupExpression(groupId, newExpression)
_ <- groupMembers.filter(_.groupId === groupId).delete
devs <- Schema.devices.filter(_.namespace === namespace).result
_ <- DBIO.sequence(devs.map(DeviceDB.toDevice(_)).map(GroupMemberRepository.addDeviceToDynamicGroups(namespace, _)))
_ <- DBIO.sequence(
devs
.map(DeviceDB.toDevice(_))
.map(GroupMemberRepository.addDeviceToDynamicGroups(namespace, _))
)
} yield ()

}
Loading

0 comments on commit 442b350

Please sign in to comment.