From 5440024038ec1b35d254a6fd9879c356d699a62c Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Thu, 29 Jan 2026 11:25:20 -0500 Subject: [PATCH] feat: Renames EffectiveLength to EquivalentLength --- Sources/DatabaseClient/EffectiveLength.swift | 22 +++++----- Sources/DatabaseClient/Interface.swift | 2 +- ...iveLength.swift => EquivalentLength.swift} | 28 ++++++------ Sources/ManualDCore/Project.swift | 4 +- Sources/ManualDCore/Routes/ApiRoute.swift | 12 ++--- Sources/ManualDCore/Routes/ViewRoute.swift | 44 +++++++++---------- Sources/PdfClient/Interface.swift | 10 ++--- .../Views/EquivalentLengthTable.swift | 4 +- Sources/ProjectClient/Interface.swift | 4 +- .../DatabaseClient+calculateDuctSizes.swift | 6 +-- .../ManualDClient+calculateDuctSizes.swift | 4 +- .../Internal/ProjectDetail+maxContainer.swift | 2 +- .../EquivalentLengthForm+extensions.swift | 8 ++-- Sources/ViewController/Live.swift | 4 +- .../EffectiveLength/EffectiveLengthForm.swift | 30 ++++++------- .../EffectiveLengthsTable.swift | 6 +-- .../EffectiveLengthsView.swift | 6 +-- .../Views/FrictionRate/FrictionRateView.swift | 2 +- .../Views/Project/ProjectView.swift | 2 +- TODO.md | 2 +- Tests/ApiRouteTests/ProjectRouteTests.swift | 4 +- .../ViewControllerTests.swift | 2 +- 22 files changed, 104 insertions(+), 104 deletions(-) rename Sources/ManualDCore/{EffectiveLength.swift => EquivalentLength.swift} (88%) diff --git a/Sources/DatabaseClient/EffectiveLength.swift b/Sources/DatabaseClient/EffectiveLength.swift index da5bd25..f6fbd9f 100644 --- a/Sources/DatabaseClient/EffectiveLength.swift +++ b/Sources/DatabaseClient/EffectiveLength.swift @@ -7,13 +7,13 @@ import ManualDCore extension DatabaseClient { @DependencyClient public struct EffectiveLengthClient: Sendable { - public var create: @Sendable (EffectiveLength.Create) async throws -> EffectiveLength - public var delete: @Sendable (EffectiveLength.ID) async throws -> Void - public var fetch: @Sendable (Project.ID) async throws -> [EffectiveLength] - public var fetchMax: @Sendable (Project.ID) async throws -> EffectiveLength.MaxContainer - public var get: @Sendable (EffectiveLength.ID) async throws -> EffectiveLength? + public var create: @Sendable (EquivalentLength.Create) async throws -> EquivalentLength + public var delete: @Sendable (EquivalentLength.ID) async throws -> Void + public var fetch: @Sendable (Project.ID) async throws -> [EquivalentLength] + public var fetchMax: @Sendable (Project.ID) async throws -> EquivalentLength.MaxContainer + public var get: @Sendable (EquivalentLength.ID) async throws -> EquivalentLength? public var update: - @Sendable (EffectiveLength.ID, EffectiveLength.Update) async throws -> EffectiveLength + @Sendable (EquivalentLength.ID, EquivalentLength.Update) async throws -> EquivalentLength } } @@ -74,7 +74,7 @@ extension DatabaseClient.EffectiveLengthClient: TestDependencyKey { } } -extension EffectiveLength.Create { +extension EquivalentLength.Create { func toModel() throws -> EffectiveLengthModel { try validate() @@ -94,7 +94,7 @@ extension EffectiveLength.Create { } } -extension EffectiveLength { +extension EquivalentLength { struct Migrate: AsyncMigration { let name = "CreateEffectiveLength" @@ -173,20 +173,20 @@ final class EffectiveLengthModel: Model, @unchecked Sendable { $project.id = projectID } - func toDTO() throws -> EffectiveLength { + func toDTO() throws -> EquivalentLength { try .init( id: requireID(), projectID: $project.id, name: name, type: .init(rawValue: type)!, straightLengths: straightLengths, - groups: JSONDecoder().decode([EffectiveLength.Group].self, from: groups), + groups: JSONDecoder().decode([EquivalentLength.Group].self, from: groups), createdAt: createdAt!, updatedAt: updatedAt! ) } - func applyUpdates(_ updates: EffectiveLength.Update) throws { + func applyUpdates(_ updates: EquivalentLength.Update) throws { if let name = updates.name, name != self.name { self.name = name } diff --git a/Sources/DatabaseClient/Interface.swift b/Sources/DatabaseClient/Interface.swift index 7fe5073..37811b8 100644 --- a/Sources/DatabaseClient/Interface.swift +++ b/Sources/DatabaseClient/Interface.swift @@ -77,7 +77,7 @@ extension DatabaseClient.Migrations: DependencyKey { ComponentPressureLoss.Migrate(), EquipmentInfo.Migrate(), Room.Migrate(), - EffectiveLength.Migrate(), + EquivalentLength.Migrate(), TrunkSize.Migrate(), ] } diff --git a/Sources/ManualDCore/EffectiveLength.swift b/Sources/ManualDCore/EquivalentLength.swift similarity index 88% rename from Sources/ManualDCore/EffectiveLength.swift rename to Sources/ManualDCore/EquivalentLength.swift index 86c42d2..3a87e9e 100644 --- a/Sources/ManualDCore/EffectiveLength.swift +++ b/Sources/ManualDCore/EquivalentLength.swift @@ -4,7 +4,7 @@ import Foundation // TODO: Not sure how to model effective length groups in the database. // thinking perhaps just have a 'data' field that encoded / decodes // to swift types?? -public struct EffectiveLength: Codable, Equatable, Identifiable, Sendable { +public struct EquivalentLength: Codable, Equatable, Identifiable, Sendable { public let id: UUID public let projectID: Project.ID @@ -19,9 +19,9 @@ public struct EffectiveLength: Codable, Equatable, Identifiable, Sendable { id: UUID, projectID: Project.ID, name: String, - type: EffectiveLength.EffectiveLengthType, + type: EquivalentLength.EffectiveLengthType, straightLengths: [Int], - groups: [EffectiveLength.Group], + groups: [EquivalentLength.Group], createdAt: Date, updatedAt: Date ) { @@ -36,7 +36,7 @@ public struct EffectiveLength: Codable, Equatable, Identifiable, Sendable { } } -extension EffectiveLength { +extension EquivalentLength { public struct Create: Codable, Equatable, Sendable { @@ -49,9 +49,9 @@ extension EffectiveLength { public init( projectID: Project.ID, name: String, - type: EffectiveLength.EffectiveLengthType, + type: EquivalentLength.EffectiveLengthType, straightLengths: [Int], - groups: [EffectiveLength.Group] + groups: [EquivalentLength.Group] ) { self.projectID = projectID self.name = name @@ -70,9 +70,9 @@ extension EffectiveLength { public init( name: String? = nil, - type: EffectiveLength.EffectiveLengthType? = nil, + type: EquivalentLength.EffectiveLengthType? = nil, straightLengths: [Int]? = nil, - groups: [EffectiveLength.Group]? = nil + groups: [EquivalentLength.Group]? = nil ) { self.name = name self.type = type @@ -107,8 +107,8 @@ extension EffectiveLength { } public struct MaxContainer: Codable, Equatable, Sendable { - public let supply: EffectiveLength? - public let `return`: EffectiveLength? + public let supply: EquivalentLength? + public let `return`: EquivalentLength? public var total: Double? { guard let supply else { return nil } @@ -116,21 +116,21 @@ extension EffectiveLength { return supply.totalEquivalentLength + `return`.totalEquivalentLength } - public init(supply: EffectiveLength? = nil, return: EffectiveLength? = nil) { + public init(supply: EquivalentLength? = nil, return: EquivalentLength? = nil) { self.supply = supply self.return = `return` } } } -extension EffectiveLength { +extension EquivalentLength { public var totalEquivalentLength: Double { straightLengths.reduce(into: 0.0) { $0 += Double($1) } + groups.totalEquivalentLength } } -extension Array where Element == EffectiveLength.Group { +extension Array where Element == EquivalentLength.Group { public var totalEquivalentLength: Double { reduce(into: 0.0) { @@ -141,7 +141,7 @@ extension Array where Element == EffectiveLength.Group { #if DEBUG - extension EffectiveLength { + extension EquivalentLength { public static func mock(projectID: Project.ID) -> [Self] { @Dependency(\.uuid) var uuid diff --git a/Sources/ManualDCore/Project.swift b/Sources/ManualDCore/Project.swift index 5ef9d36..04afc82 100644 --- a/Sources/ManualDCore/Project.swift +++ b/Sources/ManualDCore/Project.swift @@ -89,7 +89,7 @@ extension Project { public let project: Project public let componentLosses: [ComponentPressureLoss] public let equipmentInfo: EquipmentInfo - public let equivalentLengths: [EffectiveLength] + public let equivalentLengths: [EquivalentLength] public let rooms: [Room] public let trunks: [TrunkSize] @@ -97,7 +97,7 @@ extension Project { project: Project, componentLosses: [ComponentPressureLoss], equipmentInfo: EquipmentInfo, - equivalentLengths: [EffectiveLength], + equivalentLengths: [EquivalentLength], rooms: [Room], trunks: [TrunkSize] ) { diff --git a/Sources/ManualDCore/Routes/ApiRoute.swift b/Sources/ManualDCore/Routes/ApiRoute.swift index afaa5fe..e99a1e1 100644 --- a/Sources/ManualDCore/Routes/ApiRoute.swift +++ b/Sources/ManualDCore/Routes/ApiRoute.swift @@ -226,10 +226,10 @@ extension SiteRoute.Api { extension SiteRoute.Api { public enum EffectiveLengthRoute: Equatable, Sendable { - case create(EffectiveLength.Create) - case delete(id: EffectiveLength.ID) + case create(EquivalentLength.Create) + case delete(id: EquivalentLength.ID) case fetch(projectID: Project.ID) - case get(id: EffectiveLength.ID) + case get(id: EquivalentLength.ID) static let rootPath = "effectiveLength" @@ -240,12 +240,12 @@ extension SiteRoute.Api { "create" } Method.post - Body(.json(EffectiveLength.Create.self)) + Body(.json(EquivalentLength.Create.self)) } Route(.case(Self.delete(id:))) { Path { rootPath - EffectiveLength.ID.parser() + EquivalentLength.ID.parser() } Method.delete } @@ -261,7 +261,7 @@ extension SiteRoute.Api { Route(.case(Self.get(id:))) { Path { rootPath - EffectiveLength.ID.parser() + EquivalentLength.ID.parser() } Method.get } diff --git a/Sources/ManualDCore/Routes/ViewRoute.swift b/Sources/ManualDCore/Routes/ViewRoute.swift index 8414ec3..7424c52 100644 --- a/Sources/ManualDCore/Routes/ViewRoute.swift +++ b/Sources/ManualDCore/Routes/ViewRoute.swift @@ -394,11 +394,11 @@ extension SiteRoute.View.ProjectRoute { } public enum EquivalentLengthRoute: Equatable, Sendable { - case delete(id: EffectiveLength.ID) - case field(FieldType, style: EffectiveLength.EffectiveLengthType? = nil) + case delete(id: EquivalentLength.ID) + case field(FieldType, style: EquivalentLength.EffectiveLengthType? = nil) case index case submit(FormStep) - case update(EffectiveLength.ID, StepThree) + case update(EquivalentLength.ID, StepThree) static let rootPath = "effective-lengths" @@ -406,7 +406,7 @@ extension SiteRoute.View.ProjectRoute { Route(.case(Self.delete(id:))) { Path { rootPath - EffectiveLength.ID.parser() + EquivalentLength.ID.parser() } Method.delete } @@ -424,7 +424,7 @@ extension SiteRoute.View.ProjectRoute { Field("type") { FieldType.parser() } Optionally { Field("style", default: nil) { - EffectiveLength.EffectiveLengthType.parser() + EquivalentLength.EffectiveLengthType.parser() } } } @@ -437,16 +437,16 @@ extension SiteRoute.View.ProjectRoute { Route(.case(Self.update)) { Path { rootPath - EffectiveLength.ID.parser() + EquivalentLength.ID.parser() } Method.patch Body { FormData { Optionally { - Field("id", default: nil) { EffectiveLength.ID.parser() } + Field("id", default: nil) { EquivalentLength.ID.parser() } } Field("name", .string) - Field("type") { EffectiveLength.EffectiveLengthType.parser() } + Field("type") { EquivalentLength.EffectiveLengthType.parser() } Many { Field("straightLengths") { Int.parser() @@ -490,10 +490,10 @@ extension SiteRoute.View.ProjectRoute { Body { FormData { Optionally { - Field("id", default: nil) { EffectiveLength.ID.parser() } + Field("id", default: nil) { EquivalentLength.ID.parser() } } Field("name", .string) - Field("type") { EffectiveLength.EffectiveLengthType.parser() } + Field("type") { EquivalentLength.EffectiveLengthType.parser() } } .map(.memberwise(StepOne.init)) } @@ -505,10 +505,10 @@ extension SiteRoute.View.ProjectRoute { Body { FormData { Optionally { - Field("id", default: nil) { EffectiveLength.ID.parser() } + Field("id", default: nil) { EquivalentLength.ID.parser() } } Field("name", .string) - Field("type") { EffectiveLength.EffectiveLengthType.parser() } + Field("type") { EquivalentLength.EffectiveLengthType.parser() } Many { Field("straightLengths") { Int.parser() @@ -525,10 +525,10 @@ extension SiteRoute.View.ProjectRoute { Body { FormData { Optionally { - Field("id", default: nil) { EffectiveLength.ID.parser() } + Field("id", default: nil) { EquivalentLength.ID.parser() } } Field("name", .string) - Field("type") { EffectiveLength.EffectiveLengthType.parser() } + Field("type") { EquivalentLength.EffectiveLengthType.parser() } Many { Field("straightLengths") { Int.parser() @@ -567,22 +567,22 @@ extension SiteRoute.View.ProjectRoute { } public struct StepOne: Codable, Equatable, Sendable { - public let id: EffectiveLength.ID? + public let id: EquivalentLength.ID? public let name: String - public let type: EffectiveLength.EffectiveLengthType + public let type: EquivalentLength.EffectiveLengthType } public struct StepTwo: Codable, Equatable, Sendable { - public let id: EffectiveLength.ID? + public let id: EquivalentLength.ID? public let name: String - public let type: EffectiveLength.EffectiveLengthType + public let type: EquivalentLength.EffectiveLengthType public let straightLengths: [Int] public init( - id: EffectiveLength.ID? = nil, + id: EquivalentLength.ID? = nil, name: String, - type: EffectiveLength.EffectiveLengthType, + type: EquivalentLength.EffectiveLengthType, straightLengths: [Int] ) { self.id = id @@ -593,9 +593,9 @@ extension SiteRoute.View.ProjectRoute { } public struct StepThree: Codable, Equatable, Sendable { - public let id: EffectiveLength.ID? + public let id: EquivalentLength.ID? public let name: String - public let type: EffectiveLength.EffectiveLengthType + public let type: EquivalentLength.EffectiveLengthType public let straightLengths: [Int] public let groupGroups: [Int] public let groupLetters: [String] diff --git a/Sources/PdfClient/Interface.swift b/Sources/PdfClient/Interface.swift index 6aa0b05..1bc3bcd 100644 --- a/Sources/PdfClient/Interface.swift +++ b/Sources/PdfClient/Interface.swift @@ -84,8 +84,8 @@ extension PdfClient { public let componentLosses: [ComponentPressureLoss] public let ductSizes: DuctSizes public let equipmentInfo: EquipmentInfo - public let maxSupplyTEL: EffectiveLength - public let maxReturnTEL: EffectiveLength + public let maxSupplyTEL: EquivalentLength + public let maxReturnTEL: EquivalentLength public let frictionRate: FrictionRate public let projectSHR: Double @@ -99,8 +99,8 @@ extension PdfClient { componentLosses: [ComponentPressureLoss], ductSizes: DuctSizes, equipmentInfo: EquipmentInfo, - maxSupplyTEL: EffectiveLength, - maxReturnTEL: EffectiveLength, + maxSupplyTEL: EquivalentLength, + maxReturnTEL: EquivalentLength, frictionRate: FrictionRate, projectSHR: Double ) { @@ -134,7 +134,7 @@ extension PdfClient { let rooms = Room.mock(projectID: project.id) let trunks = TrunkSize.mock(projectID: project.id, rooms: rooms) let equipmentInfo = EquipmentInfo.mock(projectID: project.id) - let equivalentLengths = EffectiveLength.mock(projectID: project.id) + let equivalentLengths = EquivalentLength.mock(projectID: project.id) return .init( project: project, diff --git a/Sources/PdfClient/Views/EquivalentLengthTable.swift b/Sources/PdfClient/Views/EquivalentLengthTable.swift index a80de05..76f772a 100644 --- a/Sources/PdfClient/Views/EquivalentLengthTable.swift +++ b/Sources/PdfClient/Views/EquivalentLengthTable.swift @@ -2,7 +2,7 @@ import Elementary import ManualDCore struct EffectiveLengthsTable: HTML, Sendable { - let effectiveLengths: [EffectiveLength] + let effectiveLengths: [EquivalentLength] var body: some HTML { table { @@ -41,7 +41,7 @@ struct EffectiveLengthsTable: HTML, Sendable { } struct EffectiveLengthGroupTable: HTML, Sendable { - let groups: [EffectiveLength.Group] + let groups: [EquivalentLength.Group] var body: some HTML { table { diff --git a/Sources/ProjectClient/Interface.swift b/Sources/ProjectClient/Interface.swift index 47fd81a..2fffe2d 100644 --- a/Sources/ProjectClient/Interface.swift +++ b/Sources/ProjectClient/Interface.swift @@ -60,12 +60,12 @@ extension ProjectClient { public struct FrictionRateResponse: Codable, Equatable, Sendable { public let componentLosses: [ComponentPressureLoss] - public let equivalentLengths: EffectiveLength.MaxContainer + public let equivalentLengths: EquivalentLength.MaxContainer public let frictionRate: FrictionRate? public init( componentLosses: [ComponentPressureLoss], - equivalentLengths: EffectiveLength.MaxContainer, + equivalentLengths: EquivalentLength.MaxContainer, frictionRate: FrictionRate? = nil ) { self.componentLosses = componentLosses diff --git a/Sources/ProjectClient/Internal/DatabaseClient+calculateDuctSizes.swift b/Sources/ProjectClient/Internal/DatabaseClient+calculateDuctSizes.swift index 5e81d2a..c37aaac 100644 --- a/Sources/ProjectClient/Internal/DatabaseClient+calculateDuctSizes.swift +++ b/Sources/ProjectClient/Internal/DatabaseClient+calculateDuctSizes.swift @@ -144,11 +144,11 @@ extension DatabaseClient { // Internal container. struct DesignFrictionRateResponse: Equatable, Sendable { - typealias EnsuredTEL = (supply: EffectiveLength, return: EffectiveLength) + typealias EnsuredTEL = (supply: EquivalentLength, return: EquivalentLength) let designFrictionRate: Double let equipmentInfo: EquipmentInfo - let telMaxContainer: EffectiveLength.MaxContainer + let telMaxContainer: EquivalentLength.MaxContainer func ensureMaxContainer() throws -> EnsuredTEL { @@ -167,7 +167,7 @@ extension DatabaseClient { func designFrictionRate( componentLosses: [ComponentPressureLoss], equipmentInfo: EquipmentInfo, - equivalentLengths: EffectiveLength.MaxContainer + equivalentLengths: EquivalentLength.MaxContainer ) -> DesignFrictionRateResponse? { guard let tel = equivalentLengths.total, componentLosses.count > 0 diff --git a/Sources/ProjectClient/Internal/ManualDClient+calculateDuctSizes.swift b/Sources/ProjectClient/Internal/ManualDClient+calculateDuctSizes.swift index 4b54d2c..d0c48c1 100644 --- a/Sources/ProjectClient/Internal/ManualDClient+calculateDuctSizes.swift +++ b/Sources/ProjectClient/Internal/ManualDClient+calculateDuctSizes.swift @@ -4,8 +4,8 @@ import ManualDCore struct DuctSizeSharedRequest { let equipmentInfo: EquipmentInfo - let maxSupplyLength: EffectiveLength - let maxReturnLenght: EffectiveLength + let maxSupplyLength: EquivalentLength + let maxReturnLenght: EquivalentLength let designFrictionRate: Double let projectSHR: Double } diff --git a/Sources/ProjectClient/Internal/ProjectDetail+maxContainer.swift b/Sources/ProjectClient/Internal/ProjectDetail+maxContainer.swift index ef0e8a1..cfd4e37 100644 --- a/Sources/ProjectClient/Internal/ProjectDetail+maxContainer.swift +++ b/Sources/ProjectClient/Internal/ProjectDetail+maxContainer.swift @@ -1,7 +1,7 @@ import ManualDCore extension Project.Detail { - var maxContainer: EffectiveLength.MaxContainer { + var maxContainer: EquivalentLength.MaxContainer { .init( supply: equivalentLengths.filter({ $0.type == .supply }) .sorted(by: { $0.totalEquivalentLength > $1.totalEquivalentLength }) diff --git a/Sources/ViewController/Extensions/EquivalentLengthForm+extensions.swift b/Sources/ViewController/Extensions/EquivalentLengthForm+extensions.swift index 2b46368..fa03b6b 100644 --- a/Sources/ViewController/Extensions/EquivalentLengthForm+extensions.swift +++ b/Sources/ViewController/Extensions/EquivalentLengthForm+extensions.swift @@ -12,8 +12,8 @@ extension SiteRoute.View.ProjectRoute.EquivalentLengthRoute.StepThree { } } - var groups: [EffectiveLength.Group] { - var groups = [EffectiveLength.Group]() + var groups: [EquivalentLength.Group] { + var groups = [EquivalentLength.Group]() for (n, group) in groupGroups.enumerated() { groups.append( .init( @@ -29,7 +29,7 @@ extension SiteRoute.View.ProjectRoute.EquivalentLengthRoute.StepThree { } } -extension EffectiveLength.Create { +extension EquivalentLength.Create { init( form: SiteRoute.View.ProjectRoute.EquivalentLengthRoute.StepThree, @@ -45,7 +45,7 @@ extension EffectiveLength.Create { } } -extension EffectiveLength.Update { +extension EquivalentLength.Update { init( form: SiteRoute.View.ProjectRoute.EquivalentLengthRoute.StepThree, projectID: Project.ID diff --git a/Sources/ViewController/Live.swift b/Sources/ViewController/Live.swift index f9363fc..1d90b40 100644 --- a/Sources/ViewController/Live.swift +++ b/Sources/ViewController/Live.swift @@ -488,7 +488,7 @@ extension SiteRoute.View.ProjectRoute.EquivalentLengthRoute { switch step { case .one(let stepOne): return await ResultView { - var effectiveLength: EffectiveLength? = nil + var effectiveLength: EquivalentLength? = nil if let id = stepOne.id { effectiveLength = try await database.effectiveLength.get(id) } @@ -503,7 +503,7 @@ extension SiteRoute.View.ProjectRoute.EquivalentLengthRoute { case .two(let stepTwo): return await ResultView { request.logger.debug("ViewController: Got step two...") - var effectiveLength: EffectiveLength? = nil + var effectiveLength: EquivalentLength? = nil if let id = stepTwo.id { effectiveLength = try await database.effectiveLength.get(id) } diff --git a/Sources/ViewController/Views/EffectiveLength/EffectiveLengthForm.swift b/Sources/ViewController/Views/EffectiveLength/EffectiveLengthForm.swift index daf818d..b6b965b 100644 --- a/Sources/ViewController/Views/EffectiveLength/EffectiveLengthForm.swift +++ b/Sources/ViewController/Views/EffectiveLength/EffectiveLengthForm.swift @@ -7,7 +7,7 @@ import Styleguide struct EffectiveLengthForm: HTML, Sendable { - static func id(_ equivalentLength: EffectiveLength?) -> String { + static func id(_ equivalentLength: EquivalentLength?) -> String { let base = "equivalentLengthForm" guard let equivalentLength else { return base } return "\(base)_\(equivalentLength.id.uuidString.replacing("-", with: ""))" @@ -15,15 +15,15 @@ struct EffectiveLengthForm: HTML, Sendable { let projectID: Project.ID let dismiss: Bool - let type: EffectiveLength.EffectiveLengthType - let effectiveLength: EffectiveLength? + let type: EquivalentLength.EffectiveLengthType + let effectiveLength: EquivalentLength? var id: String { Self.id(effectiveLength) } init( projectID: Project.ID, dismiss: Bool, - type: EffectiveLength.EffectiveLengthType = .supply + type: EquivalentLength.EffectiveLengthType = .supply ) { self.projectID = projectID self.dismiss = dismiss @@ -32,7 +32,7 @@ struct EffectiveLengthForm: HTML, Sendable { } init( - effectiveLength: EffectiveLength + effectiveLength: EquivalentLength ) { self.dismiss = true self.type = effectiveLength.type @@ -55,7 +55,7 @@ struct EffectiveLengthForm: HTML, Sendable { struct StepOne: HTML, Sendable { let projectID: Project.ID - let effectiveLength: EffectiveLength? + let effectiveLength: EquivalentLength? var route: String { let baseRoute = SiteRoute.View.router.path( @@ -97,7 +97,7 @@ struct EffectiveLengthForm: HTML, Sendable { struct StepTwo: HTML, Sendable { let projectID: Project.ID let stepOne: SiteRoute.View.ProjectRoute.EquivalentLengthRoute.StepOne - let effectiveLength: EffectiveLength? + let effectiveLength: EquivalentLength? var route: String { let baseRoute = SiteRoute.View.router.path( @@ -152,7 +152,7 @@ struct EffectiveLengthForm: HTML, Sendable { struct StepThree: HTML, Sendable { let projectID: Project.ID - let effectiveLength: EffectiveLength? + let effectiveLength: EquivalentLength? let stepTwo: SiteRoute.View.ProjectRoute.EquivalentLengthRoute.StepTwo var route: String { @@ -254,10 +254,10 @@ struct StraightLengthField: HTML, Sendable { struct GroupField: HTML, Sendable { - let style: EffectiveLength.EffectiveLengthType - let group: EffectiveLength.Group? + let style: EquivalentLength.EffectiveLengthType + let group: EquivalentLength.Group? - init(style: EffectiveLength.EffectiveLengthType, group: EffectiveLength.Group? = nil) { + init(style: EquivalentLength.EffectiveLengthType, group: EquivalentLength.Group? = nil) { self.style = style self.group = group } @@ -307,7 +307,7 @@ struct GroupField: HTML, Sendable { struct GroupSelect: HTML, Sendable { - let style: EffectiveLength.EffectiveLengthType + let style: EquivalentLength.EffectiveLengthType var body: some HTML { label(.class("select")) { @@ -328,13 +328,13 @@ struct GroupSelect: HTML, Sendable { struct GroupTypeSelect: HTML, Sendable { let projectID: Project.ID - let selected: EffectiveLength.EffectiveLengthType + let selected: EquivalentLength.EffectiveLengthType var body: some HTML { label(.class("select w-full")) { span(.class("label")) { "Type" } select(.name("type"), .id("type")) { - for value in EffectiveLength.EffectiveLengthType.allCases { + for value in EquivalentLength.EffectiveLengthType.allCases { option( .value("\(value.rawValue)"), ) { value.title } @@ -345,7 +345,7 @@ struct GroupTypeSelect: HTML, Sendable { } } -extension EffectiveLength.EffectiveLengthType { +extension EquivalentLength.EffectiveLengthType { var title: String { rawValue.capitalized } diff --git a/Sources/ViewController/Views/EffectiveLength/EffectiveLengthsTable.swift b/Sources/ViewController/Views/EffectiveLength/EffectiveLengthsTable.swift index 3c42ccb..6514bbf 100644 --- a/Sources/ViewController/Views/EffectiveLength/EffectiveLengthsTable.swift +++ b/Sources/ViewController/Views/EffectiveLength/EffectiveLengthsTable.swift @@ -5,9 +5,9 @@ import Styleguide struct EffectiveLengthsTable: HTML, Sendable { - let effectiveLengths: [EffectiveLength] + let effectiveLengths: [EquivalentLength] - private var sortedLengths: [EffectiveLength] { + private var sortedLengths: [EquivalentLength] { effectiveLengths.sorted { $0.totalEquivalentLength > $1.totalEquivalentLength } @@ -55,7 +55,7 @@ struct EffectiveLengthsTable: HTML, Sendable { struct EffectiveLenghtRow: HTML, Sendable { - let effectiveLength: EffectiveLength + let effectiveLength: EquivalentLength private var deleteRoute: SiteRoute.View { .project( diff --git a/Sources/ViewController/Views/EffectiveLength/EffectiveLengthsView.swift b/Sources/ViewController/Views/EffectiveLength/EffectiveLengthsView.swift index afe7bbf..21052fc 100644 --- a/Sources/ViewController/Views/EffectiveLength/EffectiveLengthsView.swift +++ b/Sources/ViewController/Views/EffectiveLength/EffectiveLengthsView.swift @@ -7,14 +7,14 @@ struct EffectiveLengthsView: HTML, Sendable { @Environment(ProjectViewValue.$projectID) var projectID - let effectiveLengths: [EffectiveLength] + let effectiveLengths: [EquivalentLength] - var supplies: [EffectiveLength] { + var supplies: [EquivalentLength] { effectiveLengths.filter({ $0.type == .supply }) .sorted { $0.totalEquivalentLength > $1.totalEquivalentLength } } - var returns: [EffectiveLength] { + var returns: [EquivalentLength] { effectiveLengths.filter({ $0.type == .return }) .sorted { $0.totalEquivalentLength > $1.totalEquivalentLength } } diff --git a/Sources/ViewController/Views/FrictionRate/FrictionRateView.swift b/Sources/ViewController/Views/FrictionRate/FrictionRateView.swift index 2bf2ec6..9f56a71 100644 --- a/Sources/ViewController/Views/FrictionRate/FrictionRateView.swift +++ b/Sources/ViewController/Views/FrictionRate/FrictionRateView.swift @@ -8,7 +8,7 @@ struct FrictionRateView: HTML, Sendable { @Environment(ProjectViewValue.$projectID) var projectID let componentLosses: [ComponentPressureLoss] - let equivalentLengths: EffectiveLength.MaxContainer + let equivalentLengths: EquivalentLength.MaxContainer let frictionRate: FrictionRate? private var availableStaticPressure: Double? { diff --git a/Sources/ViewController/Views/Project/ProjectView.swift b/Sources/ViewController/Views/Project/ProjectView.swift index 891d2e7..e4ce1ac 100644 --- a/Sources/ViewController/Views/Project/ProjectView.swift +++ b/Sources/ViewController/Views/Project/ProjectView.swift @@ -233,7 +233,7 @@ extension ManualDClient { func frictionRate( equipmentInfo: EquipmentInfo?, componentLosses: [ComponentPressureLoss], - effectiveLength: EffectiveLength.MaxContainer + effectiveLength: EquivalentLength.MaxContainer ) async throws -> FrictionRate? { guard let staticPressure = equipmentInfo?.staticPressure else { return nil diff --git a/TODO.md b/TODO.md index 93a6a2d..a1c1240 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,7 @@ # TODO's - [x] Fix theme not working when selected upon signup. -- [ ] Pdf generation +- [x] Pdf generation - [ ] Add postgres / mysql support - [ ] Opensource / license ?? - [ ] Figure out domain to host (currently thinking ductcalc.pro) diff --git a/Tests/ApiRouteTests/ProjectRouteTests.swift b/Tests/ApiRouteTests/ProjectRouteTests.swift index b55f9ad..25d3fb0 100644 --- a/Tests/ApiRouteTests/ProjectRouteTests.swift +++ b/Tests/ApiRouteTests/ProjectRouteTests.swift @@ -78,10 +78,10 @@ struct ProjectRouteTests { let p = Body { FormData { Optionally { - Field("id", default: nil) { EffectiveLength.ID.parser() } + Field("id", default: nil) { EquivalentLength.ID.parser() } } Field("name", .string) - Field("type") { EffectiveLength.EffectiveLengthType.parser() } + Field("type") { EquivalentLength.EffectiveLengthType.parser() } Many { Field("straightLengths") { Int.parser() diff --git a/Tests/ViewControllerTests/ViewControllerTests.swift b/Tests/ViewControllerTests/ViewControllerTests.swift index bc29891..3f0bdea 100644 --- a/Tests/ViewControllerTests/ViewControllerTests.swift +++ b/Tests/ViewControllerTests/ViewControllerTests.swift @@ -86,7 +86,7 @@ struct ViewControllerTests { let project = Project.mock let rooms = Room.mock(projectID: project.id) let equipment = EquipmentInfo.mock(projectID: project.id) - let tels = EffectiveLength.mock(projectID: project.id) + let tels = EquivalentLength.mock(projectID: project.id) let componentLosses = ComponentPressureLoss.mock(projectID: project.id) let trunks = TrunkSize.mock(projectID: project.id, rooms: rooms)