Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed lint errors
Browse files Browse the repository at this point in the history
Fixed lint errors
evelyn-hur committed Mar 5, 2024
1 parent 2b3a594 commit e9e0aa3
Showing 4 changed files with 42 additions and 70 deletions.
8 changes: 8 additions & 0 deletions Prisma/PrivacyControls/DeleteDataView.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// This source file is part of the Stanford Prisma Application based on the Stanford Spezi Template Application project
//
// SPDX-FileCopyrightText: 2023 Stanford University
//
// SPDX-License-Identifier: MIT
//

//
// DeleteDataView.swift
// Prisma
8 changes: 8 additions & 0 deletions Prisma/PrivacyControls/ManageDataView.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// This source file is part of the Stanford Prisma Application based on the Stanford Spezi Template Application project
//
// SPDX-FileCopyrightText: 2023 Stanford University
//
// SPDX-License-Identifier: MIT
//

//
// ManageDataView.swift
// Prisma
85 changes: 19 additions & 66 deletions Prisma/PrivacyControls/PrivacyModule.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
//
// This source file is part of the Stanford Prisma Application based on the Stanford Spezi Template Application project
//
// SPDX-FileCopyrightText: 2023 Stanford University
//
// SPDX-License-Identifier: MIT
//


// PrivacyControls.swift
// Prisma
//
@@ -16,8 +24,13 @@ import SwiftUI


public class PrivacyModule: Module, EnvironmentAccessible {
public var iconsMapping: [String: String] =
[
public struct DataCategoryItem {
var name: String
var iconName: String
var enabledStatus: String
}

public var iconsMapping: [String: String] = [
"activeenergyburned": "flame",
"distancewalkingrunning": "figure.walk",
"heartrate": "waveform.path.ecg",
@@ -52,29 +65,22 @@ public class PrivacyModule: Module, EnvironmentAccessible {
"vo2max": "VO2 Max",
"walkingheartrateaverage": "Walking Heart Rate Average"
]

public struct DataCategoryItem {
var name: String
var iconName: String
var enabledStatus: String
}
var dataCategoryItems: [DataCategoryItem] = [];


var dataCategoryItems: [DataCategoryItem] = []
var sampleTypeList: [HKSampleType]

@StandardActor var standard: PrismaStandard

public required init(sampleTypeList: [HKSampleType]) {

Check failure on line 74 in Prisma/PrivacyControls/PrivacyModule.swift

GitHub Actions / SwiftLint / SwiftLint

Type Contents Order Violation: An 'initializer' should not be placed amongst the type content(s) 'instance_property' (type_contents_order)
self.sampleTypeList = sampleTypeList
dataCategoryItems = self.getDataCategoryItems()
self.dataCategoryItems = self.getDataCategoryItems()
}

var configuration: Configuration {
Configuration(standard: PrismaStandard()) { }
}

Check warning on line 81 in Prisma/PrivacyControls/PrivacyModule.swift

Codecov / codecov/patch

Prisma/PrivacyControls/PrivacyModule.swift#L79-L81

Added lines #L79 - L81 were not covered by tests

public func getDataCategoryItems() -> [DataCategoryItem] {
var dataCategoryItems: [DataCategoryItem] = []
// make dictionary into alphabetically sorted array of key-value tuples
let sortedDataCategoryItems = identifierUIString.sorted { $0.key < $1.key }
for dataCategoryPair in sortedDataCategoryItems {
@@ -89,66 +95,13 @@ public class PrivacyModule: Module, EnvironmentAccessible {
return dataCategoryItems
}

public func getHKSampleTypeMappings() async{
public func getHKSampleTypeMappings() async {
var toggleMapUpdated: [String: Bool] = [:]

for sampleType in sampleTypeList {
let identifier = await standard.getSampleIdentifierFromHKSampleType(sampleType: sampleType)
toggleMapUpdated[identifier ?? "Unidentified Sample Type"] = true
}

}

Check warning on line 105 in Prisma/PrivacyControls/PrivacyModule.swift

Codecov / codecov/patch

Prisma/PrivacyControls/PrivacyModule.swift#L98-L105

Added lines #L98 - L105 were not covered by tests

Check failure on line 106 in Prisma/PrivacyControls/PrivacyModule.swift

GitHub Actions / SwiftLint / SwiftLint

Vertical Whitespace before Closing Braces Violation: Don't include vertical whitespace (empty line) before closing braces (vertical_whitespace_closing_braces)

// var sampleToToggleNameMapping: [String: Bool] = [
// getSampleIdentifier(HKSample): true,
// HKQuantityType.quantityType(forIdentifier: .stepCount): "includeStepCountUpload",
// HKQuantityType.quantityType(forIdentifier: .distanceWalkingRunning): "includeDistanceWalkingRunning",
// HKQuantityType.quantityType(forIdentifier: .vo2Max): "includeVo2Max",
// HKQuantityType.quantityType(forIdentifier: .heartRate): "includeHeartRate",
// HKQuantityType.quantityType(forIdentifier: .restingHeartRate): "includeRestingHeartRate",
// HKQuantityType.quantityType(forIdentifier: .oxygenSaturation): "includeOxygenSaturation",
// HKQuantityType.quantityType(forIdentifier: .respiratoryRate): "includeRespiratoryRate",
// HKQuantityType.quantityType(forIdentifier: .walkingHeartRateAverage): "includeWalkingHeartRateAverage"
// ]


// public func getCurrentToggles() -> [String: Bool] {
// [
// "includeStepCountUpload": includeStepCountUpload,
// "includeActiveEnergyBurned": includeActiveEnergyBurned,
// "includeDistanceWalkingRunning": includeDistanceWalkingRunning,
// "includeVo2Max": includeVo2Max,
// "includeHeartRate": includeHeartRate,
// "includeRestingHeartRate": includeRestingHeartRate,
// "includeOxygenSaturation": includeOxygenSaturation,
// "includeRespiratoryRate": includeRespiratoryRate,
// "includeWalkingHRAverage": includeWalkingHRAverage
// ]
// }
// public func getLastTimestamps(quantityType: String) async -> [String] {
// var path: String = ""
//
// do {
// path = try await standard.getPath(module: .health(quantityType)) + "raw/"
// } catch {
// print("Error retrieving user document: \(error)")
// }
//
// var lastTimestampsArr: [String] = []
//
// do {
// let querySnapshot = try await Firestore.firestore().collection(path).getDocuments()
// for document in querySnapshot.documents {
// lastTimestampsArr.append(document.documentID)
//// print("\(document.documentID) => \(document.data())")
// }
// } catch {
// print("Error getting documents: \(error)")
// }
//
// return lastTimestampsArr
// }


}
11 changes: 7 additions & 4 deletions Prisma/Standard/PrismaStandard+HealthKit.swift
Original file line number Diff line number Diff line change
@@ -47,14 +47,17 @@ extension PrismaStandard {
}
}

Check warning on line 48 in Prisma/Standard/PrismaStandard+HealthKit.swift

Codecov / codecov/patch

Prisma/Standard/PrismaStandard+HealthKit.swift#L35-L48

Added lines #L35 - L48 were not covered by tests

/// Takes in HKSampleType and returns the corresponding identifier string
///
/// - Parameters:
/// - sampleType: HKSampleType to find identifier for
/// - Returns: A string for the sample type identifier.
public func getSampleIdentifierFromHKSampleType(sampleType: HKSampleType) -> String? {
if let quantityType = sampleType as? HKQuantityType {
return quantityType.identifier
}
else if let categoryType = sampleType as? HKCategoryType {
} else if let categoryType = sampleType as? HKCategoryType {
return categoryType.identifier
}
else if sampleType is HKWorkoutType {
} else if sampleType is HKWorkoutType {
return "workout"
}
// Default case for other HKSampleTypes

0 comments on commit e9e0aa3

Please sign in to comment.