COVIDSafe code from version 1.4 (#3)

This commit is contained in:
COVIDSafe Support 2020-05-26 17:13:26 +10:00 committed by GitHub
parent 56c93f2079
commit b2e0c5b34c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 6865 additions and 481 deletions

View file

@ -54,15 +54,16 @@ final class InfoViewController: UIViewController {
}
func fetchDevicesEncounteredCount() {
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
return
guard let persistentContainer =
EncounterDB.shared.persistentContainer else {
return
}
let managedContext = appDelegate.persistentContainer.viewContext
let managedContext = persistentContainer.viewContext
let fetchRequest = Encounter.fetchRequestForRecords()
do {
let devicesEncountered = try managedContext.fetch(fetchRequest)
let uniqueIDs = Set(devicesEncountered.map { $0.msg })
let uniqueIDs = Set(devicesEncountered.map { $0.timestamp })
self.devicesEncounteredLabel.text = String(uniqueIDs.count)
} catch let error as NSError {
print("Could not fetch. \(error), \(error.userInfo)")
@ -79,12 +80,29 @@ final class InfoViewController: UIViewController {
BluetraceManager.shared.toggleScanning(mySwitch.isOn)
}
@IBAction func dumpDBpressed(_ sender: UIButton) {
var activityItems: [Any] = []
let localStoreUrl = CovidPersistentContainer.defaultDirectoryURL().appendingPathComponent("tracer", isDirectory: false).appendingPathExtension("sqlite")
activityItems.append(localStoreUrl)
let localStoreUrlshm = CovidPersistentContainer.defaultDirectoryURL().appendingPathComponent("tracer", isDirectory: false).appendingPathExtension("sqlite-shm")
if FileManager.default.fileExists(atPath: localStoreUrlshm.path) {
activityItems.append(localStoreUrlshm)
}
let localStoreUrlwal = CovidPersistentContainer.defaultDirectoryURL().appendingPathComponent("tracer", isDirectory: false).appendingPathExtension("sqlite-wal")
if FileManager.default.fileExists(atPath: localStoreUrlwal.path) {
activityItems.append(localStoreUrlwal)
}
let activity = UIActivityViewController(activityItems: activityItems, applicationActivities: nil)
present(activity, animated: true, completion: nil)
}
@objc
func clearLogsButtonClicked() {
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
return
guard let persistentContainer =
EncounterDB.shared.persistentContainer else {
return
}
let managedContext = appDelegate.persistentContainer.viewContext
let managedContext = persistentContainer.viewContext
let fetchRequest = NSFetchRequest<Encounter>(entityName: "Encounter")
fetchRequest.includesPropertyValues = false
do {