Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Release Notes and Re-Enable Periphery & CodeQL #125

Merged
merged 9 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,26 @@ jobs:
uses: StanfordBDHG/.github/.github/workflows/swiftlint.yml@v2
permissions:
contents: read
# periphery:
# name: Periphery
# uses: StanfordBDHG/.github/.github/workflows/periphery.yml@v2
# permissions:
# contents: read
# with:
# runsonlabels: '["macOS", "self-hosted"]'
periphery:
name: Periphery
uses: StanfordBDHG/.github/.github/workflows/periphery.yml@v2
permissions:
contents: read
with:
runsonlabels: '["macOS", "self-hosted"]'
markdownlinkcheck:
name: Markdown Link Check
uses: StanfordBDHG/.github/.github/workflows/markdown-link-check.yml@v2
permissions:
contents: read
# codeql:
# name: CodeQL
# uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
# permissions:
# security-events: write
# actions: read
# contents: read
# with:
# codeql: true
# fastlanelane: codeql

4 changes: 0 additions & 4 deletions .periphery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,3 @@
project: ENGAGEHF.xcodeproj
schemes:
- ENGAGEHF
targets:
- ENGAGEHF
- ENGAGEHFTests
- ENGAGEHFUITests
9 changes: 4 additions & 5 deletions ENGAGEHF/ENGAGEHFStandard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ import SwiftUI


actor ENGAGEHFStandard: Standard, EnvironmentAccessible {
@Application(\.logger) private var logger

@Dependency(Account.self) private var account: Account?
@Dependency(FirebaseAccountService.self) private var accountService: FirebaseAccountService?



@Application(\.logger) private var logger


private var accountId: String {
get async throws {
guard let details = await account?.details else {
Expand Down
1 change: 0 additions & 1 deletion ENGAGEHF/HeartHealth/HeartHealth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ struct HeartHealth: View {
@Binding var presentingAccount: Bool

@Environment(NavigationManager.self) private var navigationManager
@Environment(VitalsManager.self) private var vitalsManager


var body: some View {
Expand Down
21 changes: 0 additions & 21 deletions ENGAGEHF/HeartHealth/SelectionTypes/GraphSelection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,6 @@ enum GraphSelection: CaseIterable, Identifiable, CustomStringConvertible, Equata
}
}


init(collectionRef: CollectionReference?, for accountId: String) throws {
switch collectionRef {
case Firestore.symptomScoresCollectionReference(for: accountId):
self = .symptoms
case Firestore.collectionReference(for: accountId, type: HKQuantityType(.bodyMass)):
self = .weight
case Firestore.collectionReference(for: accountId, type: HKQuantityType(.heartRate)):
self = .heartRate
case Firestore.collectionReference(for: accountId, type: HKCorrelationType(.bloodPressure)):
self = .bloodPressure
default:
throw DecodingError.valueNotFound(
CollectionReference.self,
.init(
codingPath: [],
debugDescription: "No collection matches given reference."
)
)
}
}

func collectionReference(for accountId: String) -> CollectionReference? {
switch self {
Expand Down
4 changes: 0 additions & 4 deletions ENGAGEHF/HeartHealth/SelectionTypes/SymptomsType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ enum SymptomsType: String, CaseIterable, Identifiable, CustomStringConvertible,
}
}

var localizedEmptyHistoryWarning: String {
GraphSelection.symptoms.localizedEmptyHistoryWarning
}

/// The localized description of the symptoms score
var localizedExplanation: String {
switch self {
Expand Down
4 changes: 0 additions & 4 deletions ENGAGEHF/HeartHealth/SelectionTypes/VitalsType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ enum VitalsType: CustomStringConvertible {
}
}

var localizedEmptyHistoryWarning: String {
graphType.localizedEmptyHistoryWarning
}

/// The localized description of the vitals type
var localizedExplanation: String {
switch self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ import Foundation

struct SeriesTarget {
let value: Double
let unit: String
let date: Date
let label: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,4 @@ extension Double {

return target * (((self + offsetSign * offsetMagnitude) / target).rounded(rule))
}

/// Rounds `self` to the nearest multiple of the given target, in the direction determedin by the given rule.
func roundedToNearestMultipleOf(_ target: Double, rule: FloatingPointRoundingRule = .up) -> Self {
self.roundedToNthMultipleOf(target, skipping: 0, rule: rule)
}
}
4 changes: 1 addition & 3 deletions ENGAGEHF/HeartHealth/Shared/VitalsGraph/VitalsGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import SwiftUI

struct VitalsGraph: View {
let data: SeriesDictionary
let targetValue: SeriesTarget?
let options: VitalsGraphOptions

@State private var viewModel = ViewModel()
Expand All @@ -35,9 +34,8 @@ struct VitalsGraph: View {
}


init(data: SeriesDictionary, target: SeriesTarget? = nil, options: VitalsGraphOptions = .defaultOptions) {
init(data: SeriesDictionary, options: VitalsGraphOptions = .defaultOptions) {
self.data = data
self.targetValue = target
self.options = options
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
return
}

guard let (hkUnits, unitString) = getUnits(data: [target]) else {
guard let (hkUnits, _) = getUnits(data: [target]) else {

Check warning on line 31 in ENGAGEHF/HeartHealth/Vitals/HKSampleGraph/HKSampleGraph+ViewModel.swift

View check run for this annotation

Codecov / codecov/patch

ENGAGEHF/HeartHealth/Vitals/HKSampleGraph/HKSampleGraph+ViewModel.swift#L31

Added line #L31 was not covered by tests
self.targetValue = nil
return
}
Expand All @@ -39,8 +39,6 @@
case HKQuantityTypeIdentifier.bodyMass.rawValue:
self.targetValue = SeriesTarget(
value: quantitySample.quantity.doubleValue(for: hkUnits),
unit: unitString,
date: quantitySample.startDate,
label: "Dry Weight"
)
default:
Expand Down
4 changes: 1 addition & 3 deletions ENGAGEHF/HeartHealth/VitalsList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import SwiftUI


struct VitalsList: View {
@Environment(VitalsManager.self) private var vitalsManager

var vitalSelection: GraphSelection
let vitalSelection: GraphSelection


var body: some View {
Expand Down
1 change: 1 addition & 0 deletions ENGAGEHF/Managers/ManagerProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Spezi

/// A protocol to force refresh of the content of conforming Managers.
protocol RefreshableContent {
// periphery:ignore - Actually used in the invitation code module.
@MainActor
func refreshContent()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ import SpeziFirebaseAccount
@Observable
@MainActor
final class MedicationsManager: Manager {
@ObservationIgnored @StandardActor private var standard: ENGAGEHFStandard

@ObservationIgnored @Dependency(Account.self) private var account: Account?
@ObservationIgnored @Dependency(AccountNotifications.self) private var accountNotifications: AccountNotifications?
@ObservationIgnored @Dependency(FirebaseAccountService.self) private var accountService: FirebaseAccountService?


@Application(\.logger) @ObservationIgnored private var logger

private var snapshotListener: ListenerRegistration?
Expand Down
2 changes: 2 additions & 0 deletions ENGAGEHF/Managers/MessageManager/Message.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ struct Message: Identifiable, Equatable {
let description: String?
let action: MessageAction
let isDismissible: Bool
// periphery:ignore - Currently not used in the app but a complete representation of the model.
let dueDate: Date?
// periphery:ignore - Currently not used in the app but a complete representation of the model.
let completionDate: Date?


Expand Down
6 changes: 2 additions & 4 deletions ENGAGEHF/Managers/MessageManager/MessageManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ import SpeziFirebaseAccount
@Observable
@MainActor
final class MessageManager: Manager {
@ObservationIgnored @StandardActor var standard: ENGAGEHFStandard

@ObservationIgnored @Dependency(Account.self) private var account: Account?
@ObservationIgnored @Dependency(AccountNotifications.self) private var accountNotifications: AccountNotifications?
@ObservationIgnored @Dependency(FirebaseAccountService.self) private var accountService: FirebaseAccountService?


@Application(\.logger) @ObservationIgnored private var logger

private(set) var messages: [Message] = []
Expand Down Expand Up @@ -167,6 +164,7 @@ final class MessageManager: Manager {

#if DEBUG || TEST
extension MessageManager {
// periphery:ignore - Used in Previews across the application.
/// Adds a mock message to self.messages
/// Used for testing in previews
func addMockMessage(dismissible: Bool = true, action: MessageAction = .showHealthSummary) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ final class NotificationManager: Manager, NotificationHandler, NotificationToken
@ObservationIgnored @Dependency(NavigationManager.self) private var navigationManager
@ObservationIgnored @Dependency(Account.self) private var account: Account?

// periphery:ignore - Properly used then the TEST flag is not set.
@ObservationIgnored @Application(\.registerRemoteNotifications) private var registerRemoteNotifications
@ObservationIgnored @Application(\.logger) private var logger

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import Foundation
/// Integer representation of the Decimal for use in creating Dates with time
extension Decimal {
/// Truncates the decimal and returns only the integer component as an Int
public var intValue: Int {
var intValue: Int {
Int(truncating: self as NSNumber)
}

/// Removes the whole number and returns only the fractional component as an Int, truncated to a precision of 9 decimal places
public var fracValue: Int {
var fracValue: Int {
NSDecimalNumber(decimal: self)
.subtracting(NSDecimalNumber(value: self.intValue))
.multiplying(byPowerOf10: 9)
Expand All @@ -31,7 +31,7 @@ extension Decimal {
/// Conversion to Double
extension Decimal {
/// Returns a Double representation of the Decimal
public var doubleValue: Double {
var doubleValue: Double {
NSDecimalNumber(decimal: self).doubleValue
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import ModelsR4

extension Observation {
/// Returns Observation.effective as a startDate and an endDate, if present, converting from FHIR Primitives to Swift Dates
public func getEffectiveDate() -> (start: Date, end: Date)? {
func getEffectiveDate() -> (start: Date, end: Date)? {
guard let effective else {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import HealthKit
extension HKSample {
/// Returns the Double value corresponding to each quantity in the Sample in the given units, if compatable
/// For now, only supports HKQuantitySamples and HKCorrelations
public func getDoubleValues(for unit: HKUnit) -> [String: Double] {
func getDoubleValues(for unit: HKUnit) -> [String: Double] {
switch self {
case let quantitySample as HKQuantitySample:
let quantity = quantitySample.quantity
Expand Down
20 changes: 10 additions & 10 deletions ENGAGEHF/Managers/VitalsManager/SymptomScore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
/// The score representing the result of a patient's response to a KCCQ survey
/// Parameters are specified in compliance with:
/// https://github.com/StanfordBDHG/ENGAGE-HF-Firebase/tree/web-data-scheme
public struct SymptomScore: Identifiable, Equatable {
@DocumentID public var id: String?
public let date: Date
public let overallScore: Double?
public let physicalLimitsScore: Double?
public let socialLimitsScore: Double?
public let qualityOfLifeScore: Double?
public let symptomFrequencyScore: Double?
public let dizzinessScore: Double?
struct SymptomScore: Identifiable, Equatable {
@DocumentID var id: String?
let date: Date
let overallScore: Double?
let physicalLimitsScore: Double?
let socialLimitsScore: Double?
let qualityOfLifeScore: Double?
let symptomFrequencyScore: Double?
let dizzinessScore: Double?
}


extension SymptomScore: Codable {
public init(from decoder: any Decoder) throws {
init(from decoder: any Decoder) throws {

Check warning on line 29 in ENGAGEHF/Managers/VitalsManager/SymptomScore.swift

View check run for this annotation

Codecov / codecov/patch

ENGAGEHF/Managers/VitalsManager/SymptomScore.swift#L29

Added line #L29 was not covered by tests
let container = try decoder.container(keyedBy: CodingKeys.self)

self._id = try container.decode(DocumentID<String>.self, forKey: .id)
Expand Down
25 changes: 12 additions & 13 deletions ENGAGEHF/Managers/VitalsManager/VitalsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,44 +23,43 @@ import SpeziFirestore
/// - Convert FHIR observations to HKQuantitySamples and HKCorrelations
@Observable
@MainActor
public final class VitalsManager: Manager {
final class VitalsManager: Manager {
@ObservationIgnored @StandardActor private var standard: ENGAGEHFStandard

@ObservationIgnored @Dependency(Account.self) private var account: Account?
@ObservationIgnored @Dependency(AccountNotifications.self) private var accountNotifications: AccountNotifications?
@ObservationIgnored @Dependency(FirebaseAccountService.self) private var accountService: FirebaseAccountService?


@Application(\.logger) @ObservationIgnored private var logger

private var snapshotListeners: [ListenerRegistration] = []
private var notificationsTask: Task<Void, Never>?

public var heartRateHistory: [HKQuantitySample] = []
public var bloodPressureHistory: [HKCorrelation] = []
public var weightHistory: [HKQuantitySample] = []
var heartRateHistory: [HKQuantitySample] = []
var bloodPressureHistory: [HKCorrelation] = []
var weightHistory: [HKQuantitySample] = []

public var symptomHistory: [SymptomScore] = []
var symptomHistory: [SymptomScore] = []

private(set) var latestDryWeight: HKQuantitySample?


public var latestHeartRate: HKQuantitySample? {
var latestHeartRate: HKQuantitySample? {
heartRateHistory.max { $0.startDate < $1.startDate }
}
public var latestBloodPressure: HKCorrelation? {
var latestBloodPressure: HKCorrelation? {
bloodPressureHistory.max { $0.startDate < $1.startDate }
}
public var latestWeight: HKQuantitySample? {
var latestWeight: HKQuantitySample? {
weightHistory.max { $0.startDate < $1.startDate }
}


nonisolated public init() {}
nonisolated init() {}


/// Call on initial configuration:
/// - Add a snapshot listener to the three health data collections
public func configure() {
func configure() {
if ProcessInfo.processInfo.isPreviewSimulator {
self.setupPreview()
return
Expand Down Expand Up @@ -94,7 +93,7 @@ public final class VitalsManager: Manager {
}


public func refreshContent() {
func refreshContent() {
updateSnapshotListener(for: account?.details)
}

Expand Down
2 changes: 1 addition & 1 deletion ENGAGEHF/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@
}
}
},
"You are not in this medication, but it might be helpful in the future." : {
"You are not on this medication, but it might be helpful in the future." : {
"comment" : "No action required legend entry."
},
"You are on this medication, but may benefit from a higher dose." : {
Expand Down
Loading
Loading