feat: Cleans up / moves helpers for view controller to project client.

This commit is contained in:
2026-01-16 09:31:35 -05:00
parent dbec7fb920
commit d14477e97a
10 changed files with 194 additions and 193 deletions

View File

@@ -1,78 +0,0 @@
import DatabaseClient
import Dependencies
import Fluent
import ManualDClient
import ManualDCore
import Vapor
// FIX: Remove these, not used currently.
extension DatabaseClient.Projects {
func fetchPage(
userID: User.ID,
page: Int = 1,
limit: Int = 25
) async throws -> Page<Project> {
try await fetch(userID, .init(page: page, per: limit))
}
func fetchPage(
userID: User.ID,
page: PageRequest
) async throws -> Page<Project> {
try await fetch(userID, page)
}
}
// extension DatabaseClient {
//
// func calculateDuctSizes(
// projectID: Project.ID
// ) async throws -> (rooms: [DuctSizing.RoomContainer], trunks: [DuctSizing.TrunkContainer]) {
// @Dependency(\.manualD) var manualD
//
// return try await manualD.calculate(
// rooms: rooms.fetch(projectID),
// trunks: trunkSizes.fetch(projectID),
// designFrictionRateResult: designFrictionRate(projectID: projectID),
// projectSHR: projects.getSensibleHeatRatio(projectID)
// )
// }
//
// func designFrictionRate(
// projectID: Project.ID
// ) async throws -> (EquipmentInfo, EffectiveLength.MaxContainer, Double)? {
// guard let equipmentInfo = try await equipment.fetch(projectID) else {
// return nil
// }
//
// let equivalentLengths = try await effectiveLength.fetchMax(projectID)
// guard let tel = equivalentLengths.total else { return nil }
//
// let componentLosses = try await componentLoss.fetch(projectID)
// guard componentLosses.count > 0 else { return nil }
//
// let availableStaticPressure =
// equipmentInfo.staticPressure - componentLosses.total
//
// let designFrictionRate = (availableStaticPressure * 100) / tel
//
// return (equipmentInfo, equivalentLengths, designFrictionRate)
// }
// }
extension DatabaseClient.ComponentLoss {
func createDefaults(projectID: Project.ID) async throws {
let defaults = ComponentPressureLoss.Create.default(projectID: projectID)
for loss in defaults {
_ = try await create(loss)
}
}
}
extension PageRequest {
static func next<T>(_ currentPage: Page<T>) -> Self {
.init(page: currentPage.metadata.page + 1, per: currentPage.metadata.per)
}
}

View File

@@ -1,38 +0,0 @@
// import Logging
// import ManualDClient
// import ManualDCore
//
// extension ManualDClient {
//
// func calculate(
// rooms: [Room],
// trunks: [DuctSizing.TrunkSize],
// designFrictionRateResult: (EquipmentInfo, EffectiveLength.MaxContainer, Double)?,
// projectSHR: Double?,
// logger: Logger? = nil
// ) async throws -> (rooms: [DuctSizing.RoomContainer], trunks: [DuctSizing.TrunkContainer]) {
// guard let designFrictionRateResult else { return ([], []) }
// let equipmentInfo = designFrictionRateResult.0
// let effectiveLengths = designFrictionRateResult.1
// let designFrictionRate = designFrictionRateResult.2
//
// guard let maxSupply = effectiveLengths.supply else { return ([], []) }
// guard let maxReturn = effectiveLengths.return else { return ([], []) }
//
// let ductRooms = try await self.calculateSizes(
// rooms: rooms,
// trunks: trunks,
// equipmentInfo: equipmentInfo,
// maxSupplyLength: maxSupply,
// maxReturnLength: maxReturn,
// designFrictionRate: designFrictionRate,
// projectSHR: projectSHR ?? 1.0,
// logger: logger
// )
//
// // logger?.debug("Rooms: \(ductRooms)")
//
// return ductRooms
//
// }
// }