feat: Initial csv parsing for uploading rooms for a project. Need to style the upload form.
All checks were successful
CI / Linux Tests (push) Successful in 5m41s
All checks were successful
CI / Linux Tests (push) Successful in 5m41s
This commit is contained in:
@@ -89,8 +89,8 @@ public struct DatabaseClient: Sendable {
|
||||
|
||||
@DependencyClient
|
||||
public struct Rooms: Sendable {
|
||||
public var create: @Sendable (Room.Create) async throws -> Room
|
||||
public var createMany: @Sendable ([Room.Create]) async throws -> [Room]
|
||||
public var create: @Sendable (Project.ID, Room.Create) async throws -> Room
|
||||
public var createMany: @Sendable (Project.ID, [Room.Create]) async throws -> [Room]
|
||||
public var delete: @Sendable (Room.ID) async throws -> Void
|
||||
public var deleteRectangularSize:
|
||||
@Sendable (Room.ID, Room.RectangularSize.ID) async throws -> Room
|
||||
|
||||
@@ -10,14 +10,14 @@ extension DatabaseClient.Rooms: TestDependencyKey {
|
||||
|
||||
public static func live(database: any Database) -> Self {
|
||||
.init(
|
||||
create: { request in
|
||||
let model = try request.toModel()
|
||||
create: { projectID, request in
|
||||
let model = try request.toModel(projectID: projectID)
|
||||
try await model.validateAndSave(on: database)
|
||||
return try model.toDTO()
|
||||
},
|
||||
createMany: { rooms in
|
||||
createMany: { projectID, rooms in
|
||||
try await rooms.asyncMap { request in
|
||||
let model = try request.toModel()
|
||||
let model = try request.toModel(projectID: projectID)
|
||||
try await model.validateAndSave(on: database)
|
||||
return try model.toDTO()
|
||||
}
|
||||
@@ -83,7 +83,7 @@ extension DatabaseClient.Rooms: TestDependencyKey {
|
||||
|
||||
extension Room.Create {
|
||||
|
||||
func toModel() throws -> RoomModel {
|
||||
func toModel(projectID: Project.ID) throws -> RoomModel {
|
||||
return .init(
|
||||
name: name,
|
||||
heatingLoad: heatingLoad,
|
||||
|
||||
Reference in New Issue
Block a user