feat: Adds script to generate database seeded values and removes old mock storage.

This commit is contained in:
2025-01-16 21:00:27 -05:00
parent 09b46f672a
commit e1d07008a1
16 changed files with 399 additions and 535 deletions

View File

@@ -72,3 +72,57 @@ public extension PurchaseOrder {
}
}
#if DEBUG
// public extension PurchaseOrder {
// static func generateMocks(
// count: Int = 50,
// employees: [Employee],
// users: [User],
// vendorBranches: [VendorBranch]
// ) -> [Self] {
// @Dependency(\.date.now) var now
// @Dependency(\.uuid) var uuid
//
// var output = [Self]()
//
// for id in 0 ... count {
// output.append(.init(
// id: id,
// workOrder: Int.random(in: 0 ... 100),
// materials: "Some thing",
// customer: "\(RandomNames.firstNames.randomElement()!) \(RandomNames.lastNames.randomElement()!)",
// truckStock: Bool.random(),
// createdBy: users.randomElement()!,
// createdFor: employees.randomElement()!,
// vendorBranch: vendorBranches.randomElement()!,
// createdAt: now,
// updatedAt: now
// ))
// }
//
// return output
// }
// }
public extension PurchaseOrder.Create {
static func generateMocks(
count: Int = 50,
employees: [Employee],
vendorBranches: [VendorBranch]
) -> [Self] {
precondition(employees.count > 0)
precondition(vendorBranches.count > 0)
return (0 ... count).reduce(into: [Self]()) { array, _ in
array.append(.init(
materials: "Some materials",
customer: "\(RandomNames.firstNames.randomElement()!) \(RandomNames.lastNames.randomElement()!)",
createdForID: employees.randomElement()!.id,
vendorBranchID: vendorBranches.randomElement()!.id
))
}
}
}
#endif