Mike Carman 2 недель назад
Родитель
Сommit
70597e7abf
8 измененных файлов: 255 добавлений и 17 удалений
  1. Двоичные данные
      .swiftpm/xcode/package.xcworkspace/xcuserdata/mcarman.xcuserdatad/UserInterfaceState.xcuserstate
  2. +224
    -8
      .swiftpm/xcode/xcuserdata/mcarman.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  3. +5
    -2
      Sources/App/Controllers/V2.2/FuelEntryControllerV2_2.swift
  4. +1
    -1
      Sources/App/DTO/V2.2/v2.2.swift
  5. +14
    -0
      Sources/App/Migrations/CreateFuelEntry.swift
  6. +8
    -6
      Sources/App/Models/FuelEntry.swift
  7. +1
    -0
      Sources/App/configure.swift
  8. +2
    -0
      Sources/App/routes.swift

Двоичные данные
.swiftpm/xcode/package.xcworkspace/xcuserdata/mcarman.xcuserdatad/UserInterfaceState.xcuserstate Просмотреть файл


+ 224
- 8
.swiftpm/xcode/xcuserdata/mcarman.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist Просмотреть файл

@@ -14,8 +14,8 @@
filePath = "Sources/App/Models/FuelEntry.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "245"
endingLineNumber = "245"
startingLineNumber = "247"
endingLineNumber = "247"
landmarkName = "init(id:timestamp:userID:latitude:longitude:product:make:model:serialNumber:tankID:fuelAmount:fuelType:isOverride:tabletserial:uniqueID:)"
landmarkType = "7">
</BreakpointContent>
@@ -30,8 +30,8 @@
filePath = "Sources/App/Models/FuelEntry.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "224"
endingLineNumber = "224"
startingLineNumber = "225"
endingLineNumber = "225"
landmarkName = "init(id:timestamp:userID:latitude:longitude:image:product:make:model:serialNumber:tankID:fuelAmount:fuelType:isOverride:tabletserial:uniqueID:)"
landmarkType = "7">
</BreakpointContent>
@@ -174,8 +174,8 @@
filePath = "Sources/App/Models/FuelEntry.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "291"
endingLineNumber = "291"
startingLineNumber = "293"
endingLineNumber = "293"
landmarkName = "init(from:)"
landmarkType = "7">
</BreakpointContent>
@@ -222,8 +222,8 @@
filePath = "Sources/App/Models/FuelEntry.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "297"
endingLineNumber = "297"
startingLineNumber = "299"
endingLineNumber = "299"
landmarkName = "init(from:)"
landmarkType = "7">
</BreakpointContent>
@@ -260,5 +260,221 @@
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "41995477-EE00-40B0-82C8-77CE86AB02D9"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Sources/App/Controllers/V2.2/FuelEntryControllerV2_2.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "655"
endingLineNumber = "655"
landmarkName = "create(req:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "453CDD8B-F708-48F9-A903-483CC4F2C2F6"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Sources/App/Controllers/V2.2/FuelEntryControllerV2_2.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "663"
endingLineNumber = "663"
landmarkName = "create(req:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "8E150450-9BCE-4BF7-A6EB-404074E2B086"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Sources/App/Controllers/V2.2/FuelEntryControllerV2_2.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "680"
endingLineNumber = "680"
landmarkName = "create(req:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "9C0D83E8-7F5C-4097-B58F-6EC149EABA42"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Sources/App/DTO/V2.2/v2.2.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "66"
endingLineNumber = "66"
landmarkName = "init(from:img:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "AC2EE12C-8447-43D6-8C1E-489E4925645E"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Sources/App/Controllers/V2.2/FuelEntryControllerV2_2.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "657"
endingLineNumber = "657"
landmarkName = "create(req:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "597F55FD-D311-466E-B34B-0DDB9CE84EF7"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Sources/App/Controllers/V2.2/FuelEntryControllerV2_2.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "662"
endingLineNumber = "662"
landmarkName = "create(req:)"
landmarkType = "7">
<Locations>
<Location
uuid = "597F55FD-D311-466E-B34B-0DDB9CE84EF7 - 5e5e325c6c7819"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "(1) suspend resume partial function for App.FuelEntryV2ControllerV2_2.create(req: Vapor.Request) async throws -&gt; Vapor.Response"
moduleName = "App"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/mcarman/Projects/Vapor/fueling_v1/Sources/App/Controllers/V2.2/FuelEntryControllerV2_2.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "662"
endingLineNumber = "662">
</Location>
<Location
uuid = "597F55FD-D311-466E-B34B-0DDB9CE84EF7 - a3880bf45864dc29"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "(2) await resume partial function for App.FuelEntryV2ControllerV2_2.create(req: Vapor.Request) async throws -&gt; Vapor.Response"
moduleName = "App"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/mcarman/Projects/Vapor/fueling_v1/Sources/App/Controllers/V2.2/FuelEntryControllerV2_2.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "662"
endingLineNumber = "662">
</Location>
<Location
uuid = "597F55FD-D311-466E-B34B-0DDB9CE84EF7 - 77ba241e02573c1f"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "(3) suspend resume partial function for App.FuelEntryV2ControllerV2_2.create(req: Vapor.Request) async throws -&gt; Vapor.Response"
moduleName = "App"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/mcarman/Projects/Vapor/fueling_v1/Sources/App/Controllers/V2.2/FuelEntryControllerV2_2.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "662"
endingLineNumber = "662">
</Location>
<Location
uuid = "597F55FD-D311-466E-B34B-0DDB9CE84EF7 - 807568474ee04413"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "(7) suspend resume partial function for App.FuelEntryV2ControllerV2_2.create(req: Vapor.Request) async throws -&gt; Vapor.Response"
moduleName = "App"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/mcarman/Projects/Vapor/fueling_v1/Sources/App/Controllers/V2.2/FuelEntryControllerV2_2.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "662"
endingLineNumber = "662">
</Location>
<Location
uuid = "597F55FD-D311-466E-B34B-0DDB9CE84EF7 - dba6dded7e84bc3a"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "(10) suspend resume partial function for App.FuelEntryV2ControllerV2_2.create(req: Vapor.Request) async throws -&gt; Vapor.Response"
moduleName = "App"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/mcarman/Projects/Vapor/fueling_v1/Sources/App/Controllers/V2.2/FuelEntryControllerV2_2.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "662"
endingLineNumber = "662">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "E380BBC5-32F7-4E93-95AD-15814A7DFB10"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Sources/App/DTO/V2.2/v2.2.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "67"
endingLineNumber = "67"
landmarkName = "init(from:img:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "642CF5F2-CE21-45F9-A85F-9A3481C10567"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Sources/App/Controllers/V2.2/FuelEntryControllerV2_2.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "661"
endingLineNumber = "661"
landmarkName = "create(req:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "6BAA281D-5395-4922-B90D-9833111DD7AF"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Sources/App/Controllers/V2.2/FuelEntryControllerV2_2.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "660"
endingLineNumber = "660"
landmarkName = "create(req:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>

+ 5
- 2
Sources/App/Controllers/V2.2/FuelEntryControllerV2_2.swift Просмотреть файл

@@ -653,10 +653,13 @@ struct FuelEntryV2ControllerV2_2: RouteCollection {
func create(req: Request) async throws -> Response {
let fuelEntry = try req.content.decode([FuelEntry.V2_2_Input].self)
var results: [FuelEntry] = []
for entry in fuelEntry {
let uuid = entry.uniqueID
let input = FuelEntry.init(from: entry)
let exists = try await FuelEntry.query(on: req.db).filter(\.$uniqueID, .equal, input.uniqueID).first()
let exists = try await FuelEntry.query(on: req.db).filter(\.$uniqueID, .equal, uuid).first()
if(exists == nil) {
let data = entry.image ?? nil
let length = data?.count
@@ -683,7 +686,7 @@ struct FuelEntryV2ControllerV2_2: RouteCollection {
// try await fuelEntry.create(on: req.db)
let response = try await results.map{
try FuelEntry.V2_1_Output.init(from: $0)
try FuelEntry.V2_2_Output.init(from: $0)
}.encodeResponse(for: req)
return response
}


+ 1
- 1
Sources/App/DTO/V2.2/v2.2.swift Просмотреть файл

@@ -63,7 +63,7 @@ extension FuelEntry {
if img {
self.image = decoder.image
}
self.uniqueID = decoder.uniqueID?.uuidString
self.uniqueID = decoder.uniqueID
}
}


+ 14
- 0
Sources/App/Migrations/CreateFuelEntry.swift Просмотреть файл

@@ -110,6 +110,20 @@ struct AddUniqueIDFiled: AsyncMigration {
}
}

struct ChangeUniqueIDFiled: AsyncMigration {
func prepare(on database: Database) async throws {
try await database.schema("fuel_entries")
.updateField("unique_id", .string)
.update()
}
func revert(on database: Database) async throws {
try await database.schema("fuel_entries")
.updateField("unique_id", .uuid)
.update()
}
}

struct AddAppVersion: AsyncMigration {
func prepare(on database: Database) async throws {
try await database.schema("fuel_entries")


+ 8
- 6
Sources/App/Models/FuelEntry.swift Просмотреть файл

@@ -170,13 +170,13 @@ final class FuelEntry: Model, Content {
@Timestamp(key: "loadDate", on: .create) var loaddate: Date?
@Timestamp(key: "pullDate", on: .none) var pulldate: Date?
@Field(key: "unique_id") var uniqueID: UUID?
@Field(key: "unique_id") var uniqueID: String?
// var imageData: Data?
init() {}
init(id: UUID? = nil, timestamp: Date, userID: String, latitude: Double, longitude: Double, image: Data?, product: String, make: String, model: String, serialNumber: String, tankID: String, fuelAmount: Double, fuelType: String, isOverride: Bool, downloaded: Bool? = nil, tabletserial: String? = nil, appversion: String? = nil, uniqueID: UUID? = nil) { //imageData: Data?
init(id: UUID? = nil, timestamp: Date, userID: String, latitude: Double, longitude: Double, image: Data?, product: String, make: String, model: String, serialNumber: String, tankID: String, fuelAmount: Double, fuelType: String, isOverride: Bool, downloaded: Bool? = nil, tabletserial: String? = nil, appversion: String? = nil, uniqueID: String? = nil) { //imageData: Data?
self.id = id
self.timestamp = timestamp
self.userID = userID
@@ -199,7 +199,7 @@ final class FuelEntry: Model, Content {
// self.imageData = imageData
}
init(id: UUID? = nil, timestamp: Date, userID: String, latitude: Double, longitude: Double, image: Data?, product: String, make: String, model: String, serialNumber: String, tankID: String, fuelAmount: Double, fuelType: String, isOverride: Bool, downloaded: Bool? = nil, tabletserial: String? = nil, uniqueID: UUID? = nil) { //imageData: Data?
init(id: UUID? = nil, timestamp: Date, userID: String, latitude: Double, longitude: Double, image: Data?, product: String, make: String, model: String, serialNumber: String, tankID: String, fuelAmount: Double, fuelType: String, isOverride: Bool, downloaded: Bool? = nil, tabletserial: String? = nil, uniqueID: String? = nil) { //imageData: Data?
self.id = id
self.timestamp = timestamp
self.userID = userID
@@ -220,7 +220,8 @@ final class FuelEntry: Model, Content {
self.uniqueID = uniqueID
// self.imageData = imageData
}
init(id: UUID? = nil, timestamp: Date, userID: String, latitude: Double, longitude: Double, image: Data?, product: String, make: String, model: String, serialNumber: String, tankID: String, fuelAmount: Double, fuelType: String, isOverride: Bool, tabletserial: String? = nil, uniqueID: UUID? = nil) { //imageData: Data?
init(id: UUID? = nil, timestamp: Date, userID: String, latitude: Double, longitude: Double, image: Data?, product: String, make: String, model: String, serialNumber: String, tankID: String, fuelAmount: Double, fuelType: String, isOverride: Bool, tabletserial: String? = nil, uniqueID: String? = nil) { //imageData: Data?
self.id = id
self.timestamp = timestamp
self.userID = userID
@@ -241,7 +242,8 @@ final class FuelEntry: Model, Content {
self.uniqueID = uniqueID
// self.imageData = imageData
}
init(id: UUID? = nil, timestamp: Date, userID: String, latitude: Double, longitude: Double, product: String, make: String, model: String, serialNumber: String, tankID: String, fuelAmount: Double, fuelType: String, isOverride: Bool, tabletserial: String? = nil, uniqueID: UUID? = nil) { //imageData: Data?
init(id: UUID? = nil, timestamp: Date, userID: String, latitude: Double, longitude: Double, product: String, make: String, model: String, serialNumber: String, tankID: String, fuelAmount: Double, fuelType: String, isOverride: Bool, tabletserial: String? = nil, uniqueID: String? = nil) { //imageData: Data?
self.id = id
self.timestamp = timestamp
self.userID = userID
@@ -317,6 +319,6 @@ final class FuelEntry: Model, Content {
self.image = decoder.image
self.tabletserial = decoder.tabletSerial ?? ""
self.downloaded = false
self.uniqueID = decoder.uniqueID == nil ? nil : UUID(uuidString: decoder.uniqueID!)
self.uniqueID = decoder.uniqueID
}
}

+ 1
- 0
Sources/App/configure.swift Просмотреть файл

@@ -53,6 +53,7 @@ public func configure(_ app: Application) async throws {
app.migrations.add(AddDeviceSerial())
app.migrations.add(AddAppVersion())
app.migrations.add(AddUniqueIDFiled())
app.migrations.add(ChangeUniqueIDFiled())
try await app.autoMigrate().get()

// register routes


+ 2
- 0
Sources/App/routes.swift Просмотреть файл

@@ -6,6 +6,8 @@ func routes(_ app: Application) throws {
app.routes.defaultMaxBodySize = "64mb";
let V2_1 = app.grouped("api").grouped("v2.1")
try V2_1.register(collection: FuelEntryV2ControllerV2_1())
let v2_2 = app.grouped("api").grouped("v2.2")
try v2_2.register(collection: FuelEntryV2ControllerV2_2())
let v2 = app.grouped("api").grouped("v2")
try v2.register(collection: FuelEntryV2Controller())
try v2.register(collection: UserController())


Загрузка…
Отмена
Сохранить