feat: Renames EffectiveLength to EquivalentLength
All checks were successful
CI / Linux Tests (push) Successful in 9m34s
All checks were successful
CI / Linux Tests (push) Successful in 9m34s
This commit is contained in:
@@ -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
|
||||
@@ -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]
|
||||
) {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user