Skip to content

Commit b4f0791

Browse files
author
Achyut Kumar M
committed
add exclude_gig_tags
1 parent 5dc75a3 commit b4f0791

File tree

16 files changed

+90
-76
lines changed

16 files changed

+90
-76
lines changed

GoInfoGame/GoInfoGame/DataBase/DatabaseConnector.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,7 @@ class DatabaseConnector {
369369
- parameter tags [String:String] tags changed with this
370370
- Returns: An instance of `StoredChangeset`
371371
*/
372-
func createChangeset(id:String, type: StoredElementEnum, tags:[String:String], isUndo: Bool) -> StoredChangeset? {
373-
if isUndo { return nil }
374-
372+
func createChangeset(id:String, type: StoredElementEnum, tags:[String:String]) -> StoredChangeset? {
375373
let storedChangeset = StoredChangeset()
376374
storedChangeset.elementId = id
377375
storedChangeset.elementType = type

GoInfoGame/GoInfoGame/data/DatasyncManager.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ class DatasyncManager {
2020
private let dbInstance = DatabaseConnector.shared
2121
private let barrierQueue: DispatchQueue = DispatchQueue(label: "com.goinfogame.DatasyncManager.barrierQueue", attributes: .concurrent)
2222

23-
func syncDataToOSM(completionHandler: @escaping (Result<Bool, APIError>) -> Void) {
23+
func syncDataToOSM(exclude_gig_tags: Bool, completionHandler: @escaping (Result<Bool, APIError>) -> Void) {
2424
barrierQueue.async(flags: .barrier) { [weak self] in
2525
guard let self = self else { return }
2626
let semaphore = DispatchSemaphore(value: 0)
2727

2828
Task.detached(priority: .userInitiated) {
2929
do {
30-
let isSynced = try await self.syncData()
30+
let isSynced = try await self.syncData(exclude_gig_tags: exclude_gig_tags)
3131

3232
print("Sync finished")
3333
if isSynced {
@@ -57,7 +57,7 @@ class DatasyncManager {
5757
/// *** Terminating app due to uncaught exception 'RLMException', reason: 'Realm accessed from incorrect thread.'
5858
/// To fix the above error added @mainActor
5959
@MainActor
60-
func syncData() async throws -> Bool {
60+
func syncData(exclude_gig_tags: Bool = false) async throws -> Bool {
6161
print("🔄 Starting sync...")
6262

6363
let changesets = dbInstance.getChangesets()
@@ -132,7 +132,7 @@ class DatasyncManager {
132132
print("📤 Syncing way ID: \(way.id)")
133133
let payload = way.asOSMWay()
134134
do {
135-
let isFinished = try await syncWay(way: payload)
135+
let isFinished = try await syncWay(way: payload, exclude_gig_tags: exclude_gig_tags)
136136
if isFinished {
137137
DispatchQueue.main.async {
138138
self.dbInstance.assignChangesetId(obj: key, changesetId: 0)
@@ -195,7 +195,7 @@ class DatasyncManager {
195195
}
196196
}
197197

198-
func openChangeset() async throws -> Int {
198+
func openChangeset(exclude_gig_tags: Bool = false) async throws -> Int {
199199
var versionNumber = ""
200200
var buildNumber = ""
201201

@@ -206,7 +206,7 @@ class DatasyncManager {
206206
}
207207

208208
let createdBy = "\(versionNumber)(\(buildNumber))"
209-
let osmPayloadString = OSMChangesetPayload(createdByTag: createdBy).toPayload()
209+
let osmPayloadString = OSMChangesetPayload(createdByTag: createdBy).toPayload(exclude_gig_tags: exclude_gig_tags)
210210
let osmPayload = osmPayloadString.data(using: .utf8)
211211
let workspaceId = KeychainManager.load(key: "workspaceID")
212212

@@ -252,9 +252,9 @@ class DatasyncManager {
252252
}
253253

254254
// utility function to act as substitute for osmConnection functions
255-
func updateWay(way: OSMWay) async throws -> Int {
255+
func updateWay(way: OSMWay, exclude_gig_tags: Bool = false) async throws -> Int {
256256
var localWay = way
257-
let wayBodyString = localWay.toPayload()
257+
let wayBodyString = localWay.toPayload(exclude_gig_tags: exclude_gig_tags)
258258
let changesetUploadBody = "<osmChange version=\"0.6\" generator=\"GIG Change generator\">" + wayBodyString + "</osmChange>"
259259
let workspaceId = KeychainManager.load(key: "workspaceID")
260260
let wayBody = changesetUploadBody.data(using: .utf8)
@@ -288,9 +288,9 @@ class DatasyncManager {
288288
}
289289

290290
// utility function to act as substitute for osmConnection functions
291-
func updateNode(node: OSMNode) async throws -> Int {
291+
func updateNode(node: OSMNode, exclude_gig_tags: Bool = false) async throws -> Int {
292292
var localNode = node
293-
let nodeBodyString = localNode.toPayload()
293+
let nodeBodyString = localNode.toPayload(exclude_gig_tags: exclude_gig_tags)
294294
let changesetUploadBody = "<osmChange version=\"0.6\" generator=\"GIG Change generator\">" + nodeBodyString + "</osmChange>"
295295
let workspaceId = KeychainManager.load(key: "workspaceID")
296296

@@ -330,9 +330,9 @@ class DatasyncManager {
330330
}
331331
}
332332

333-
func uploadNode(node: OSMNode) async throws -> Bool {
333+
func uploadNode(node: OSMNode, exclude_gig_tags: Bool = false) async throws -> Bool {
334334
var localNode = node
335-
let nodeBodyString = localNode.toCreatePayload()
335+
let nodeBodyString = localNode.toCreatePayload(exclude_gig_tags: exclude_gig_tags)
336336
let changesetUploadBody = "<osmChange version=\"0.6\" generator=\"GIG Change generator\">" + nodeBodyString + "</osmChange>"
337337
let workspaceId = KeychainManager.load(key: "workspaceID")
338338

@@ -356,12 +356,12 @@ class DatasyncManager {
356356
}
357357
}
358358

359-
func updateWay2(way: OSMWay) async throws -> Int {
359+
func updateWay2(way: OSMWay, exclude_gig_tags: Bool = false) async throws -> Int {
360360
var localWay = way
361361
let wayId = "\(localWay.id)"
362362
var updatedResult: Int = -1
363363
do {
364-
updatedResult = try await updateWay(way: localWay)
364+
updatedResult = try await updateWay(way: localWay, exclude_gig_tags: exclude_gig_tags)
365365
return updatedResult
366366
} catch let error as APIError {
367367
switch error {
@@ -551,7 +551,7 @@ class DatasyncManager {
551551
}
552552

553553
@MainActor
554-
func syncWay(way: OSMWay) async throws -> Bool {
554+
func syncWay(way: OSMWay, exclude_gig_tags: Bool = false) async throws -> Bool {
555555
var localWay = way
556556

557557
do {
@@ -560,7 +560,7 @@ class DatasyncManager {
560560

561561
localWay.changeset = changesetID
562562

563-
let newVersion = try await updateWay2(way: localWay)
563+
let newVersion = try await updateWay2(way: localWay, exclude_gig_tags: exclude_gig_tags)
564564

565565
localWay.version = newVersion
566566

GoInfoGame/GoInfoGame/quests/BusStopLit/BusStopLit.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class BusStopLit: QuestBase, Quest {
6464

6565
func onAnswer(answer: YesNoAnswer) {
6666
if let rData = self.relationData {
67-
self.updateTags(id: rData.id, tags: ["lit":answer.rawValue], type: rData.type)
67+
self.updateTags(id: rData.id, tags: ["lit":answer.rawValue], type: rData.type, exclude_gig_tags: false)
6868
}
6969
}
7070

GoInfoGame/GoInfoGame/quests/QuestProtocols.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ class QuestBase {
3939

4040
// Add a custom implementation
4141

42-
public func updateTags(id: Int64, tags:[String:String], type: ElementType, isUndo: Bool = false) {
42+
public func updateTags(id: Int64, tags:[String:String], type: ElementType, exclude_gig_tags: Bool = false) {
4343

4444
MapUndoManager.shared.updateTagsHandler = { [weak self] id, tags, type in
45-
self?.updateTags(id: id, tags: tags, type: type)
45+
self?.updateTags(id: id, tags: tags, type: type, exclude_gig_tags: true)
4646
}
4747

4848

4949
// Convert from ElementType enum to StoredElementEnum
5050
let storedElementType: StoredElementEnum = type == .way ? .way : .node
5151
let storedId = String(id)
5252
// Create a changeset
53-
_ = DatabaseConnector.shared.createChangeset(id: storedId, type: storedElementType, tags: tags, isUndo: isUndo)
53+
_ = DatabaseConnector.shared.createChangeset(id: storedId, type: storedElementType, tags: tags)
5454
switch (storedElementType){
5555
case .way:
5656
elementSubmittingToPOSM = .way
@@ -66,7 +66,7 @@ class QuestBase {
6666
// Dismiss sheet after syncing to db
6767
MapViewPublisher.shared.dismissSheet.send(.syncing)
6868

69-
DatasyncManager.shared.syncDataToOSM { success in
69+
DatasyncManager.shared.syncDataToOSM(exclude_gig_tags: exclude_gig_tags) { success in
7070
DispatchQueue.main.async {
7171
MapViewPublisher.shared.dismissSheet.send(.synced)
7272

GoInfoGame/GoInfoGame/quests/SidewalkSurface/SidewalkSurface.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class SidewalkSurface: QuestBase, Quest {
3939

4040
func onAnswer(answer: SidewalkSurfaceAnswer) {
4141
if let rData = self.relationData , let surface = answer.value.surface?.rawValue {
42-
self.updateTags(id: rData.id, tags: ["surface":surface], type: rData.type)
42+
self.updateTags(id: rData.id, tags: ["surface":surface], type: rData.type, exclude_gig_tags: false)
4343
}
4444
}
4545

GoInfoGame/GoInfoGame/quests/SidewalkWidth/SideWalkWidth.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class SideWalkWidth : QuestBase, Quest {
5353

5454
func onAnswer(answer: WidthAnswer) {
5555
if let rData = self.relationData {
56-
self.updateTags(id: rData.id, tags: ["width":answer.width], type: rData.type)
56+
self.updateTags(id: rData.id, tags: ["width":answer.width], type: rData.type, exclude_gig_tags: false)
5757
}
5858
}
5959

GoInfoGame/GoInfoGame/quests/StairNumber/StairNumber.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class StairNumber: QuestBase, Quest {
4949

5050
func onAnswer(answer: Int) {
5151
if let rData = self.relationData {
52-
self.updateTags(id: rData.id, tags: ["step_count":"\(answer)"], type: rData.type)
52+
self.updateTags(id: rData.id, tags: ["step_count":"\(answer)"], type: rData.type, exclude_gig_tags: false)
5353
}
5454
}
5555

GoInfoGame/GoInfoGame/quests/StepsIncline/StepsIncline.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class StepsIncline: QuestBase, Quest {
5050

5151
func onAnswer(answer: StepsInclineDirection) {
5252
if let rData = self.relationData {
53-
self.updateTags(id: rData.id, tags: ["climb":answer.rawValue], type: rData.type)
53+
self.updateTags(id: rData.id, tags: ["climb":answer.rawValue], type: rData.type, exclude_gig_tags: false)
5454
}
5555
}
5656

GoInfoGame/GoInfoGame/quests/TactilePavingCrosswalk/TactilePavingCrosswalk.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class TactilePavingCrosswalk :QuestBase, Quest {
5353

5454
func onAnswer(answer: YesNoAnswer) {
5555
if let rData = self.relationData {
56-
self.updateTags(id: rData.id, tags: ["tactile_paving":answer.rawValue], type: rData.type)
56+
self.updateTags(id: rData.id, tags: ["tactile_paving":answer.rawValue], type: rData.type, exclude_gig_tags: false)
5757
}
5858
}
5959

GoInfoGame/osmapi/BaseNetworkManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class BaseNetworkManager {
140140

141141
do {
142142
// Encode the request body
143-
let data = body.toPayload()
143+
let data = body.toPayload(exclude_gig_tags: false)
144144
request.httpBody = data.data(using: .utf8)
145145

146146
URLSession.shared.dataTask(with: request) { data, response, error in

0 commit comments

Comments
 (0)