Skip to content

Commit 8cf0a87

Browse files
authored
Merge pull request #275 from TaskarCenterAtUW/BUG-2071-Very-slow-quest-download
Bug 2071 very slow quest download
2 parents 7943508 + bf7e667 commit 8cf0a87

File tree

21 files changed

+72549
-203
lines changed

21 files changed

+72549
-203
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,4 @@ fastlane/test_output
9090
# https://github.com/johnno1962/injectionforxcode
9191

9292
iOSInjectionProject/
93+
GoInfoGame/.DS_Store

GoInfoGame/.DS_Store

-8 KB
Binary file not shown.

GoInfoGame/GoInfoGame.xcodeproj/project.pbxproj

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
0513BE772B2B464800FB61CF /* samplepoint.gpx in Resources */ = {isa = PBXBuildFile; fileRef = 0513BE762B2B464800FB61CF /* samplepoint.gpx */; };
1110
0536DD852B0BD11A00B04C4B /* LoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0536DD842B0BD11A00B04C4B /* LoginViewController.swift */; };
1211
0536DD8C2B0BD2C200B04C4B /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0536DD8B2B0BD2C200B04C4B /* Constants.swift */; };
1312
0536DD922B0BD58800B04C4B /* OAuthService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0536DD912B0BD58800B04C4B /* OAuthService.swift */; };
@@ -143,6 +142,11 @@
143142
A4E711A82B57CA4300C9DE08 /* QuestsRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4E711A72B57CA4300C9DE08 /* QuestsRepository.swift */; };
144143
B0CCB98C2B8626AE00AA73DE /* ProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0CCB98B2B8626AE00AA73DE /* ProfileView.swift */; };
145144
B0CCB98E2B8626C600AA73DE /* ProfileViewVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0CCB98D2B8626C600AA73DE /* ProfileViewVM.swift */; };
145+
C75666D02E0D068900D36C41 /* OHHTTPStubs in Frameworks */ = {isa = PBXBuildFile; productRef = C75666CF2E0D068900D36C41 /* OHHTTPStubs */; };
146+
C75666D22E0D068900D36C41 /* OHHTTPStubsSwift in Frameworks */ = {isa = PBXBuildFile; productRef = C75666D12E0D068900D36C41 /* OHHTTPStubsSwift */; };
147+
C75CC5D92E0D22F4008A94A0 /* LongQuestsResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = C75CC5D82E0D22F4008A94A0 /* LongQuestsResponse.json */; };
148+
C75CC5DA2E0D22F4008A94A0 /* Workspaces response.json in Resources */ = {isa = PBXBuildFile; fileRef = C75CC5D62E0D22F4008A94A0 /* Workspaces response.json */; };
149+
C75CC5DB2E0D22F4008A94A0 /* SCLIO Seattle pins response.json in Resources */ = {isa = PBXBuildFile; fileRef = C75CC5D72E0D22F4008A94A0 /* SCLIO Seattle pins response.json */; };
146150
C75EAD362E042D4500F75969 /* SideWalkWidth.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4E711A12B57A3B400C9DE08 /* SideWalkWidth.swift */; };
147151
C75EAD372E042D4500F75969 /* SideWalkWidthForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 973FC0132B4D353800878269 /* SideWalkWidthForm.swift */; };
148152
C76187DC2E0153D800150201 /* ClusterMap in Frameworks */ = {isa = PBXBuildFile; productRef = C76187DB2E0153D800150201 /* ClusterMap */; };
@@ -473,6 +477,10 @@
473477
B0CCB98B2B8626AE00AA73DE /* ProfileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileView.swift; sourceTree = "<group>"; };
474478
B0CCB98D2B8626C600AA73DE /* ProfileViewVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileViewVM.swift; sourceTree = "<group>"; };
475479
C4F37DA661B22FA87DF8282F /* Pods_osmapi.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_osmapi.framework; sourceTree = BUILT_PRODUCTS_DIR; };
480+
C75CC5D62E0D22F4008A94A0 /* Workspaces response.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "Workspaces response.json"; sourceTree = "<group>"; };
481+
C75CC5D72E0D22F4008A94A0 /* SCLIO Seattle pins response.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "SCLIO Seattle pins response.json"; sourceTree = "<group>"; };
482+
C75CC5D82E0D22F4008A94A0 /* LongQuestsResponse.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = LongQuestsResponse.json; sourceTree = "<group>"; };
483+
C75E47732E151058006D903A /* Kondapur.gpx */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Kondapur.gpx; sourceTree = "<group>"; };
476484
C77A4A252DF2AF3100DED8B0 /* SecureInputView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecureInputView.swift; sourceTree = "<group>"; };
477485
C77EEBCE2DE59D3200494CB4 /* UndoMerge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UndoMerge.swift; sourceTree = "<group>"; };
478486
C7ED070E2D70E2EC001FFFE2 /* TokenRefresher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokenRefresher.swift; sourceTree = "<group>"; };
@@ -592,6 +600,8 @@
592600
isa = PBXFrameworksBuildPhase;
593601
buildActionMask = 2147483647;
594602
files = (
603+
C75666D02E0D068900D36C41 /* OHHTTPStubs in Frameworks */,
604+
C75666D22E0D068900D36C41 /* OHHTTPStubsSwift in Frameworks */,
595605
97F2FA8A2B0630A3000B9726 /* Pods_GoInfoGame.framework in Frameworks */,
596606
A4AD13272B5E90BD0041A881 /* osmparser.framework in Frameworks */,
597607
C76187DC2E0153D800150201 /* ClusterMap in Frameworks */,
@@ -630,6 +640,7 @@
630640
0536DD8A2B0BD2A900B04C4B /* Helpers */ = {
631641
isa = PBXGroup;
632642
children = (
643+
C75CC5D52E0D22E0008A94A0 /* SampleResponses */,
633644
0536DD8B2B0BD2C200B04C4B /* Constants.swift */,
634645
972454142B14A49A0036B91A /* Extensions.swift */,
635646
973FBFFD2B46BB3800878269 /* Utils.swift */,
@@ -1253,6 +1264,16 @@
12531264
path = Profile;
12541265
sourceTree = "<group>";
12551266
};
1267+
C75CC5D52E0D22E0008A94A0 /* SampleResponses */ = {
1268+
isa = PBXGroup;
1269+
children = (
1270+
C75CC5D62E0D22F4008A94A0 /* Workspaces response.json */,
1271+
C75CC5D72E0D22F4008A94A0 /* SCLIO Seattle pins response.json */,
1272+
C75CC5D82E0D22F4008A94A0 /* LongQuestsResponse.json */,
1273+
);
1274+
path = SampleResponses;
1275+
sourceTree = "<group>";
1276+
};
12561277
FA18CADE2CC7CD46008247F2 /* Kartaview */ = {
12571278
isa = PBXGroup;
12581279
children = (
@@ -1449,6 +1470,7 @@
14491470
FAD5C4F82AFCBE700040C61A /* Main.storyboard */,
14501471
FAD5C4FB2AFCBE720040C61A /* Assets.xcassets */,
14511472
0513BE762B2B464800FB61CF /* samplepoint.gpx */,
1473+
C75E47732E151058006D903A /* Kondapur.gpx */,
14521474
FAD5C4FD2AFCBE720040C61A /* LaunchScreen.storyboard */,
14531475
FAD5C5002AFCBE720040C61A /* Info.plist */,
14541476
A40004EB2B62338400AF21FB /* AppQuestManager.swift */,
@@ -1777,6 +1799,7 @@
17771799
mainGroup = FAD5C4E62AFCBE700040C61A;
17781800
packageReferences = (
17791801
C76187DA2E0153D800150201 /* XCRemoteSwiftPackageReference "ClusterMap" */,
1802+
C75666CE2E0D068900D36C41 /* XCRemoteSwiftPackageReference "OHHTTPStubs" */,
17801803
);
17811804
productRefGroup = FAD5C4F02AFCBE700040C61A /* Products */;
17821805
projectDirPath = "";
@@ -1827,10 +1850,12 @@
18271850
buildActionMask = 2147483647;
18281851
files = (
18291852
973FC00A2B4D2A6D00878269 /* Localizable.strings in Resources */,
1830-
0513BE772B2B464800FB61CF /* samplepoint.gpx in Resources */,
18311853
FAD5C4FF2AFCBE720040C61A /* LaunchScreen.storyboard in Resources */,
18321854
FAD5C4FC2AFCBE720040C61A /* Assets.xcassets in Resources */,
18331855
FAD5C4FA2AFCBE700040C61A /* Main.storyboard in Resources */,
1856+
C75CC5D92E0D22F4008A94A0 /* LongQuestsResponse.json in Resources */,
1857+
C75CC5DA2E0D22F4008A94A0 /* Workspaces response.json in Resources */,
1858+
C75CC5DB2E0D22F4008A94A0 /* SCLIO Seattle pins response.json in Resources */,
18341859
);
18351860
runOnlyForDeploymentPostprocessing = 0;
18361861
};
@@ -2899,6 +2924,14 @@
28992924
/* End XCConfigurationList section */
29002925

29012926
/* Begin XCRemoteSwiftPackageReference section */
2927+
C75666CE2E0D068900D36C41 /* XCRemoteSwiftPackageReference "OHHTTPStubs" */ = {
2928+
isa = XCRemoteSwiftPackageReference;
2929+
repositoryURL = "https://github.com/AliSoftware/OHHTTPStubs";
2930+
requirement = {
2931+
kind = upToNextMajorVersion;
2932+
minimumVersion = 9.1.0;
2933+
};
2934+
};
29022935
C76187DA2E0153D800150201 /* XCRemoteSwiftPackageReference "ClusterMap" */ = {
29032936
isa = XCRemoteSwiftPackageReference;
29042937
repositoryURL = "https://github.com/vospennikov/ClusterMap.git";
@@ -2910,6 +2943,16 @@
29102943
/* End XCRemoteSwiftPackageReference section */
29112944

29122945
/* Begin XCSwiftPackageProductDependency section */
2946+
C75666CF2E0D068900D36C41 /* OHHTTPStubs */ = {
2947+
isa = XCSwiftPackageProductDependency;
2948+
package = C75666CE2E0D068900D36C41 /* XCRemoteSwiftPackageReference "OHHTTPStubs" */;
2949+
productName = OHHTTPStubs;
2950+
};
2951+
C75666D12E0D068900D36C41 /* OHHTTPStubsSwift */ = {
2952+
isa = XCSwiftPackageProductDependency;
2953+
package = C75666CE2E0D068900D36C41 /* XCRemoteSwiftPackageReference "OHHTTPStubs" */;
2954+
productName = OHHTTPStubsSwift;
2955+
};
29132956
C76187DB2E0153D800150201 /* ClusterMap */ = {
29142957
isa = XCSwiftPackageProductDependency;
29152958
package = C76187DA2E0153D800150201 /* XCRemoteSwiftPackageReference "ClusterMap" */;

GoInfoGame/GoInfoGame.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GoInfoGame/GoInfoGame/AppQuestManager.swift

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ class AppQuestManager {
2626
private let seedBox = BBox(minLat: 47.70312160869372, maxLat: 47.718964653825054, minLon: -122.20866792353317, maxLon: -122.18570621653987)
2727

2828
func getUpdatedQuest(elementId: String) -> DisplayUnitWithCoordinate? {
29-
let nodesFromStorage = dbInstance.getNodes().filter { n in
30-
n.tags.count != 0
31-
}
32-
let waysFromStorage = dbInstance.getWays().filter{w in w.tags.count != 0 }
29+
let nodesFromStorage = dbInstance.getNodes(NSPredicate(format: "tags.@count != 0"))
30+
let waysFromStorage = dbInstance.getWays(NSPredicate(format: "tags.@count != 0"))
3331
let theWay = waysFromStorage.first(where: {$0.id == Int64(elementId)})
3432
let theNode = nodesFromStorage.first(where: {$0.id == Int64(elementId)})
3533
let allQuests = QuestsRepository.shared.applicableQuests
@@ -68,53 +66,40 @@ class AppQuestManager {
6866

6967
// Fetches all the available quests from Database
7068
func fetchQuestsFromDB() -> [DisplayUnitWithCoordinate] {
71-
72-
let allOriginalNodes = dbInstance.getNodes().filter {$0.tags.count != 0 && ($0.point.latitude != 0.0 || $0.point.longitude != 0.0)}
73-
74-
75-
var nodesFromStorage: [StoredNode] = []
76-
for node in allOriginalNodes {
77-
autoreleasepool {
78-
if node.tags["ext:gig_complete"] != "yes" {
79-
nodesFromStorage.append(node)
80-
}
81-
}
82-
}
83-
84-
let allOriginalWays = dbInstance.getWays().filter {
85-
$0.tags.count != 0 && !$0.polyline.isEmpty
86-
}
87-
88-
var waysFromStorage: [StoredWay] = []
8969

90-
for way in allOriginalWays {
91-
autoreleasepool {
92-
if way.tags["ext:gig_complete"] != "yes" {
93-
waysFromStorage.append(way)
94-
}
95-
}
96-
}
97-
70+
let nodesFromStorage = dbInstance.getNodes(NSPredicate(format: """
71+
tags.@count != 0 AND
72+
tags['ext:gig_complete'] != 'yes'
73+
"""))
9874

75+
let waysFromStorage = dbInstance.getWays(NSPredicate(format: """
76+
tags.@count != 0 AND
77+
polyline.@count > 0 AND
78+
tags['ext:gig_complete'] != 'yes'
79+
""" ))
80+
debugPrint("converting to nods: start \(Date())")
9981
let nodeElements = nodesFromStorage.map({ node in
10082
autoreleasepool {
10183
node.asNode()
10284
}
10385
})
86+
debugPrint("converting to nods: end \(Date())")
87+
debugPrint("converting to way: start \(Date())")
10488
let wayElements = waysFromStorage.map({ way in
10589
autoreleasepool {
10690
way.asWay()
10791
}
10892

10993
})
110-
94+
95+
debugPrint("converting to way: end \(Date())")
11196
// Get the quests for nodes
11297
var nodeQuests: [any Quest] = []
11398
var wayQuests: [any Quest] = []
11499
let allQuests = QuestsRepository.shared.applicableQuests
115100
var displayUnits : [DisplayUnitWithCoordinate] = []
116101

117-
102+
debugPrint("process nodes: start: \(Date())")
118103
// Get the quests for ways
119104
for node in nodeElements {
120105
// Get the quests and try to iterate
@@ -132,6 +117,8 @@ class AppQuestManager {
132117

133118
}
134119
}
120+
debugPrint("process nodes: end: \(Date())")
121+
debugPrint("process ways: start: \(Date())")
135122
for way in wayElements{
136123
for quest in allQuests {
137124
if quest.quest.filter.isEmpty {continue} // Ignore quest
@@ -147,6 +134,7 @@ class AppQuestManager {
147134
}
148135
}
149136
}
137+
debugPrint("process ways: end: \(Date())")
150138
print("Sending back items")
151139
print(allQuests)
152140

GoInfoGame/GoInfoGame/DataBase/DBModels/StoredNode.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ class StoredNode : Object {
1717
@Persisted(primaryKey: true) var id: Int64
1818
@Persisted var tags = Map<String,String>()
1919
@Persisted var version: Int = 0
20-
@Persisted var timestamp : String = ""
21-
@Persisted var point: CLLocationCoordinate2D = CLLocationCoordinate2D(latitude: 0.0, longitude: 0.0)
20+
@Persisted var timestamp : Date
21+
@Persisted var latitude: Double = 0.0 // Store as separate properties
22+
@Persisted var longitude: Double = 0.0
23+
// @Persisted var point: CLLocationCoordinate2D = CLLocationCoordinate2D(latitude: 0.0, longitude: 0.0)
2224

2325
// Give another method that gives node
2426
public func asNode() -> Node {
25-
let position = LatLon(latitude: point.latitude , longitude: point.longitude)
27+
let position = LatLon(latitude: latitude , longitude: longitude)
2628
var theTags: [String:String] = [:]
2729
for (key,value) in tags{
2830
theTags[key] = value

GoInfoGame/GoInfoGame/DataBase/DBModels/StoredWay.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class StoredWay: Object {
1818
@Persisted(primaryKey: true) var id: Int64
1919
@Persisted var tags = Map<String,String>()
2020
@Persisted var version: Int = 0
21-
@Persisted var timestamp : String = ""
21+
@Persisted var timestamp : Date
2222
@Persisted var nodes: List<Int64> = List<Int64>()
2323
// Need to persist the points
2424
@Persisted var polyline: List<CLLocationCoordinate2D> = List<CLLocationCoordinate2D>()

0 commit comments

Comments
 (0)