feat: Moves rectangular size to room namespace instead of under duct sizing, since it's stored on the room database model.
This commit is contained in:
@@ -10,12 +10,11 @@ extension DatabaseClient {
|
|||||||
public var create: @Sendable (Room.Create) async throws -> Room
|
public var create: @Sendable (Room.Create) async throws -> Room
|
||||||
public var delete: @Sendable (Room.ID) async throws -> Void
|
public var delete: @Sendable (Room.ID) async throws -> Void
|
||||||
public var deleteRectangularSize:
|
public var deleteRectangularSize:
|
||||||
@Sendable (Room.ID, DuctSizing.RectangularDuct.ID) async throws -> Room
|
@Sendable (Room.ID, Room.RectangularSize.ID) async throws -> Room
|
||||||
public var get: @Sendable (Room.ID) async throws -> Room?
|
public var get: @Sendable (Room.ID) async throws -> Room?
|
||||||
public var fetch: @Sendable (Project.ID) async throws -> [Room]
|
public var fetch: @Sendable (Project.ID) async throws -> [Room]
|
||||||
public var update: @Sendable (Room.ID, Room.Update) async throws -> Room
|
public var update: @Sendable (Room.ID, Room.Update) async throws -> Room
|
||||||
public var updateRectangularSize:
|
public var updateRectangularSize: @Sendable (Room.ID, Room.RectangularSize) async throws -> Room
|
||||||
@Sendable (Room.ID, DuctSizing.RectangularDuct) async throws -> Room
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +203,7 @@ final class RoomModel: Model, @unchecked Sendable {
|
|||||||
var registerCount: Int
|
var registerCount: Int
|
||||||
|
|
||||||
@Field(key: "rectangularSizes")
|
@Field(key: "rectangularSizes")
|
||||||
var rectangularSizes: [DuctSizing.RectangularDuct]?
|
var rectangularSizes: [Room.RectangularSize]?
|
||||||
|
|
||||||
@Timestamp(key: "createdAt", on: .create, format: .iso8601)
|
@Timestamp(key: "createdAt", on: .create, format: .iso8601)
|
||||||
var createdAt: Date?
|
var createdAt: Date?
|
||||||
@@ -224,7 +223,7 @@ final class RoomModel: Model, @unchecked Sendable {
|
|||||||
coolingTotal: Double,
|
coolingTotal: Double,
|
||||||
coolingSensible: Double? = nil,
|
coolingSensible: Double? = nil,
|
||||||
registerCount: Int,
|
registerCount: Int,
|
||||||
rectangularSizes: [DuctSizing.RectangularDuct]? = nil,
|
rectangularSizes: [Room.RectangularSize]? = nil,
|
||||||
createdAt: Date? = nil,
|
createdAt: Date? = nil,
|
||||||
updatedAt: Date? = nil,
|
updatedAt: Date? = nil,
|
||||||
projectID: Project.ID
|
projectID: Project.ID
|
||||||
|
|||||||
@@ -3,27 +3,9 @@ import Foundation
|
|||||||
|
|
||||||
public enum DuctSizing {
|
public enum DuctSizing {
|
||||||
|
|
||||||
public struct RectangularDuct: Codable, Equatable, Identifiable, Sendable {
|
|
||||||
|
|
||||||
public let id: UUID
|
|
||||||
public let register: Int?
|
|
||||||
public let height: Int
|
|
||||||
|
|
||||||
public init(
|
|
||||||
id: UUID = .init(),
|
|
||||||
register: Int? = nil,
|
|
||||||
height: Int,
|
|
||||||
) {
|
|
||||||
self.id = id
|
|
||||||
self.register = register
|
|
||||||
self.height = height
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct SizeContainer: Codable, Equatable, Sendable {
|
public struct SizeContainer: Codable, Equatable, Sendable {
|
||||||
|
|
||||||
public let rectangularID: RectangularDuct.ID?
|
public let rectangularID: Room.RectangularSize.ID?
|
||||||
public let designCFM: DesignCFM
|
public let designCFM: DesignCFM
|
||||||
public let roundSize: Double
|
public let roundSize: Double
|
||||||
public let finalSize: Int
|
public let finalSize: Int
|
||||||
@@ -33,7 +15,7 @@ public enum DuctSizing {
|
|||||||
public let width: Int?
|
public let width: Int?
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
rectangularID: RectangularDuct.ID? = nil,
|
rectangularID: Room.RectangularSize.ID? = nil,
|
||||||
designCFM: DuctSizing.DesignCFM,
|
designCFM: DuctSizing.DesignCFM,
|
||||||
roundSize: Double,
|
roundSize: Double,
|
||||||
finalSize: Int,
|
finalSize: Int,
|
||||||
@@ -87,41 +69,6 @@ public enum DuctSizing {
|
|||||||
self.ductSize = ductSize
|
self.ductSize = ductSize
|
||||||
}
|
}
|
||||||
|
|
||||||
// public init(
|
|
||||||
// roomID: Room.ID,
|
|
||||||
// roomName: String,
|
|
||||||
// roomRegister: Int,
|
|
||||||
// heatingLoad: Double,
|
|
||||||
// coolingLoad: Double,
|
|
||||||
// heatingCFM: Double,
|
|
||||||
// coolingCFM: Double,
|
|
||||||
// designCFM: DesignCFM,
|
|
||||||
// roundSize: Double,
|
|
||||||
// finalSize: Int,
|
|
||||||
// velocity: Int,
|
|
||||||
// flexSize: Int,
|
|
||||||
// rectangularSize: RectangularDuct? = nil,
|
|
||||||
// rectangularWidth: Int? = nil
|
|
||||||
// ) {
|
|
||||||
// self.roomID = roomID
|
|
||||||
// self.roomName = roomName
|
|
||||||
// self.roomRegister = roomRegister
|
|
||||||
// self.heatingLoad = heatingLoad
|
|
||||||
// self.coolingLoad = coolingLoad
|
|
||||||
// self.heatingCFM = heatingCFM
|
|
||||||
// self.coolingCFM = coolingCFM
|
|
||||||
// self.ductSize = .init(
|
|
||||||
// rectangularID: rectangularSize?.id,
|
|
||||||
// designCFM: designCFM,
|
|
||||||
// roundSize: roundSize,
|
|
||||||
// finalSize: finalSize,
|
|
||||||
// velocity: velocity,
|
|
||||||
// flexSize: flexSize,
|
|
||||||
// height: rectangularSize?.height,
|
|
||||||
// width: rectangularWidth
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
|
|
||||||
public subscript<T>(dynamicMember keyPath: KeyPath<DuctSizing.SizeContainer, T>) -> T {
|
public subscript<T>(dynamicMember keyPath: KeyPath<DuctSizing.SizeContainer, T>) -> T {
|
||||||
ductSize[keyPath: keyPath]
|
ductSize[keyPath: keyPath]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public struct Room: Codable, Equatable, Identifiable, Sendable {
|
|||||||
public let coolingTotal: Double
|
public let coolingTotal: Double
|
||||||
public let coolingSensible: Double?
|
public let coolingSensible: Double?
|
||||||
public let registerCount: Int
|
public let registerCount: Int
|
||||||
public let rectangularSizes: [DuctSizing.RectangularDuct]?
|
public let rectangularSizes: [RectangularSize]?
|
||||||
public let createdAt: Date
|
public let createdAt: Date
|
||||||
public let updatedAt: Date
|
public let updatedAt: Date
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ public struct Room: Codable, Equatable, Identifiable, Sendable {
|
|||||||
coolingTotal: Double,
|
coolingTotal: Double,
|
||||||
coolingSensible: Double? = nil,
|
coolingSensible: Double? = nil,
|
||||||
registerCount: Int = 1,
|
registerCount: Int = 1,
|
||||||
rectangularSizes: [DuctSizing.RectangularDuct]? = nil,
|
rectangularSizes: [RectangularSize]? = nil,
|
||||||
createdAt: Date,
|
createdAt: Date,
|
||||||
updatedAt: Date
|
updatedAt: Date
|
||||||
) {
|
) {
|
||||||
@@ -65,13 +65,30 @@ extension Room {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public struct RectangularSize: Codable, Equatable, Identifiable, Sendable {
|
||||||
|
|
||||||
|
public let id: UUID
|
||||||
|
public let register: Int?
|
||||||
|
public let height: Int
|
||||||
|
|
||||||
|
public init(
|
||||||
|
id: UUID = .init(),
|
||||||
|
register: Int? = nil,
|
||||||
|
height: Int,
|
||||||
|
) {
|
||||||
|
self.id = id
|
||||||
|
self.register = register
|
||||||
|
self.height = height
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public struct Update: Codable, Equatable, Sendable {
|
public struct Update: Codable, Equatable, Sendable {
|
||||||
public let name: String?
|
public let name: String?
|
||||||
public let heatingLoad: Double?
|
public let heatingLoad: Double?
|
||||||
public let coolingTotal: Double?
|
public let coolingTotal: Double?
|
||||||
public let coolingSensible: Double?
|
public let coolingSensible: Double?
|
||||||
public let registerCount: Int?
|
public let registerCount: Int?
|
||||||
public let rectangularSizes: [DuctSizing.RectangularDuct]?
|
public let rectangularSizes: [RectangularSize]?
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
name: String? = nil,
|
name: String? = nil,
|
||||||
@@ -89,7 +106,7 @@ extension Room {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
rectangularSizes: [DuctSizing.RectangularDuct]
|
rectangularSizes: [RectangularSize]
|
||||||
) {
|
) {
|
||||||
self.name = nil
|
self.name = nil
|
||||||
self.heatingLoad = nil
|
self.heatingLoad = nil
|
||||||
|
|||||||
@@ -627,7 +627,7 @@ extension SiteRoute.View.ProjectRoute {
|
|||||||
}
|
}
|
||||||
Method.delete
|
Method.delete
|
||||||
Query {
|
Query {
|
||||||
Field("rectangularSize") { DuctSizing.RectangularDuct.ID.parser() }
|
Field("rectangularSize") { Room.RectangularSize.ID.parser() }
|
||||||
Field("register") { Int.parser() }
|
Field("register") { Int.parser() }
|
||||||
}
|
}
|
||||||
.map(.memberwise(DeleteRectangularDuct.init))
|
.map(.memberwise(DeleteRectangularDuct.init))
|
||||||
@@ -642,7 +642,7 @@ extension SiteRoute.View.ProjectRoute {
|
|||||||
Body {
|
Body {
|
||||||
FormData {
|
FormData {
|
||||||
Optionally {
|
Optionally {
|
||||||
Field("id") { DuctSizing.RectangularDuct.ID.parser() }
|
Field("id") { Room.RectangularSize.ID.parser() }
|
||||||
}
|
}
|
||||||
Field("register") { Int.parser() }
|
Field("register") { Int.parser() }
|
||||||
Field("height") { Int.parser() }
|
Field("height") { Int.parser() }
|
||||||
@@ -658,10 +658,10 @@ extension SiteRoute.View.ProjectRoute {
|
|||||||
|
|
||||||
public struct DeleteRectangularDuct: Equatable, Sendable {
|
public struct DeleteRectangularDuct: Equatable, Sendable {
|
||||||
|
|
||||||
public let rectangularSizeID: DuctSizing.RectangularDuct.ID
|
public let rectangularSizeID: Room.RectangularSize.ID
|
||||||
public let register: Int
|
public let register: Int
|
||||||
|
|
||||||
public init(rectangularSizeID: DuctSizing.RectangularDuct.ID, register: Int) {
|
public init(rectangularSizeID: Room.RectangularSize.ID, register: Int) {
|
||||||
self.rectangularSizeID = rectangularSizeID
|
self.rectangularSizeID = rectangularSizeID
|
||||||
self.register = register
|
self.register = register
|
||||||
}
|
}
|
||||||
@@ -732,7 +732,7 @@ extension SiteRoute.View.ProjectRoute {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public struct RoomRectangularForm: Equatable, Sendable {
|
public struct RoomRectangularForm: Equatable, Sendable {
|
||||||
public let id: DuctSizing.RectangularDuct.ID?
|
public let id: Room.RectangularSize.ID?
|
||||||
public let register: Int
|
public let register: Int
|
||||||
public let height: Int
|
public let height: Int
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ extension DuctSizing.SizeContainer {
|
|||||||
init(
|
init(
|
||||||
designCFM: DuctSizing.DesignCFM,
|
designCFM: DuctSizing.DesignCFM,
|
||||||
sizes: ManualDClient.DuctSizeResponse,
|
sizes: ManualDClient.DuctSizeResponse,
|
||||||
rectangularSize: DuctSizing.RectangularDuct?,
|
rectangularSize: Room.RectangularSize?,
|
||||||
width: Int?
|
width: Int?
|
||||||
) {
|
) {
|
||||||
self.init(
|
self.init(
|
||||||
|
|||||||
Reference in New Issue
Block a user