From a9f3b286d4e03f7a9f7439007c09dafe38ae14cd Mon Sep 17 00:00:00 2001 From: Nevin Joshy Date: Fri, 22 Sep 2023 15:01:18 -0400 Subject: [PATCH 1/4] Started working on issue with unknown bus location. Working on case for location type of network --- Sources/App/routes.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/App/routes.swift b/Sources/App/routes.swift index 1429b8c..006988a 100644 --- a/Sources/App/routes.swift +++ b/Sources/App/routes.swift @@ -383,6 +383,9 @@ func routes(_ application: Application) throws { .query(on: request.db(.sqlite)) .filter(\.$id == id) .first() + if bus==nil && location.type=={ + + } guard let bus = bus else { throw Abort(.notFound) } From 10f4c7e5e9e46ec0208138292203ab26b5bf3cd1 Mon Sep 17 00:00:00 2001 From: Nevin Joshy Date: Tue, 3 Oct 2023 11:46:48 -0400 Subject: [PATCH 2/4] Checking if type of location is through network --- Sources/App/routes.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/App/routes.swift b/Sources/App/routes.swift index 006988a..711bf3d 100644 --- a/Sources/App/routes.swift +++ b/Sources/App/routes.swift @@ -379,12 +379,12 @@ func routes(_ application: Application) throws { guard isOnRoute else { throw Abort(.conflict) } - let bus = try await Bus + var bus = try await Bus .query(on: request.db(.sqlite)) .filter(\.$id == id) .first() - if bus==nil && location.type=={ - + if bus == nil && location.type == .network { + bus = Bus(id: id) } guard let bus = bus else { throw Abort(.notFound) From d668b73821eaef9ca155a6ffb6d020aeccd9c5a4 Mon Sep 17 00:00:00 2001 From: Nevin Joshy Date: Fri, 6 Oct 2023 16:34:43 -0400 Subject: [PATCH 3/4] Finished issue with unknown bus locations --- Sources/App/routes.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/App/routes.swift b/Sources/App/routes.swift index 711bf3d..7eca0a8 100644 --- a/Sources/App/routes.swift +++ b/Sources/App/routes.swift @@ -385,6 +385,7 @@ func routes(_ application: Application) throws { .first() if bus == nil && location.type == .network { bus = Bus(id: id) + try await bus?.save(on: request.db(.sqlite)) } guard let bus = bus else { throw Abort(.notFound) From c4461d62cd020484f8eaec5c485879229be3ae22 Mon Sep 17 00:00:00 2001 From: Nevin Joshy Date: Tue, 31 Oct 2023 16:26:13 -0400 Subject: [PATCH 4/4] Added check for network location type --- Sources/App/routes.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/App/routes.swift b/Sources/App/routes.swift index 7eca0a8..0b02606 100644 --- a/Sources/App/routes.swift +++ b/Sources/App/routes.swift @@ -375,7 +375,7 @@ func routes(_ application: Application) throws { } let isOnRoute = !routes.allSatisfy { (route) in return !route.checkIsOnRoute(location: location) - } + } || location.type == .network guard isOnRoute else { throw Abort(.conflict) }