Skip to content

Commit

Permalink
1.2.1 hotfix to develop (#1301)
Browse files Browse the repository at this point in the history
* Calculate time windows using milliseconds

* Incremented release version number

Co-authored-by: Rob Visentin <[email protected]>
  • Loading branch information
JacobJaffe and jvisenti authored Jul 21, 2020
1 parent eb4a568 commit c21d7fb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions ios/COVIDSafePathsTests/MARULocation+ExtensionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import XCTest
class MAURLocation_ExtensionTests: XCTestCase {

func testTimeWindow() {
let date = Date(timeIntervalSince1970: 1586865792000)
let date = Date(timeIntervalSince1970: 1586865792)
let backgroundLocation = TestMAURLocation(latitude: 41.24060321, longitude: 14.91328448, date: date)
let windows = backgroundLocation.timeWindows(interval: 60 * 5 * 1000)
XCTAssertEqual(windows.early, 1586865600000)
XCTAssertEqual(windows.late, 1586865900000)
}

func testScryptHashSpec() {
let date = Date(timeIntervalSince1970: 1589117939000)
let date = Date(timeIntervalSince1970: 1589117939)
let backgroundLocation = TestMAURLocation(latitude: 41.24060321, longitude: 14.91328448, date: date)
let scryptHashes = backgroundLocation.geoHashes

Expand All @@ -44,7 +44,7 @@ class MAURLocation_ExtensionTests: XCTestCase {
}

func testValidScrypt() {
let date = Date(timeIntervalSince1970: 1589117939000)
let date = Date(timeIntervalSince1970: 1589117939)
let backgroundLocation = TestMAURLocation(latitude: 41.24060321, longitude: 14.91328448, date: date)
let scryptHashes = backgroundLocation.scryptHashes
let expectedHashes = [
Expand Down
4 changes: 2 additions & 2 deletions ios/GPS/Config/Version.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ MARKETING_VERSION = 1.0.0
CURRENT_PROJECT_VERSION = 8

// Release
MARKETING_VERSION[config=Release-GPS] = 1.2.0
CURRENT_PROJECT_VERSION[config=Release-GPS] = 2
MARKETING_VERSION[config=Release-GPS] = 1.2.1
CURRENT_PROJECT_VERSION[config=Release-GPS] = 1
16 changes: 9 additions & 7 deletions ios/GPS/Extension/MAURLocation+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extension MAURLocation {
}).reduce(into: Set<String>(), { (hashes, currentLocation) in
hashes.insert(Geohash.encode(latitude: currentLocation.0, longitude: currentLocation.1, length: 8))
}).reduce(into: [String](), { (hashes, hash) in
let timeWindow = timeWindows(interval: Double(60 * 5 * 1000))
let timeWindow = timeWindows(interval: 60 * 5 * 1000)
hashes.append("\(hash)\(timeWindow.early)")
hashes.append("\(hash)\(timeWindow.late)")
})
Expand Down Expand Up @@ -55,13 +55,15 @@ extension MAURLocation {
}

/// Generates rounded time windows for interval before and after timestamp
/// https://pathcheck.atlassian.net/wiki/x/CoDXB
/// - Parameters:
/// - interval: location storage interval in seconds
public func timeWindows(interval: TimeInterval) -> (early: Int, late: Int) {
let time1 = Int(((time.timeIntervalSince1970 - interval / 2) / interval).rounded(.down) * interval)
let time2 = Int(((time.timeIntervalSince1970 + interval / 2) / interval).rounded(.down) * interval)
return (time1, time2)
/// - interval: location storage interval in milliseconds
public func timeWindows(interval: Int64) -> (early: Int64, late: Int64) {
let ms = Int64(time.timeIntervalSince1970 * 1000.0)

let early = (ms - interval / 2) / interval * interval
let late = (ms + interval / 2) / interval * interval

return (early, late)
}

/// Apply scrypt hash algorithm on a String
Expand Down

0 comments on commit c21d7fb

Please sign in to comment.