Skip to content

Commit

Permalink
Add Periphery Setup
Browse files Browse the repository at this point in the history
  • Loading branch information
PSchmiedmayer committed Nov 21, 2024
1 parent 4f4dad3 commit 2cedcb6
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 73 deletions.
15 changes: 15 additions & 0 deletions .periphery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# This source file is part of the PAWS application based on the Stanford Spezi Template Application project
#
# SPDX-FileCopyrightText: 2023 Stanford University
#
# SPDX-License-Identifier: MIT
#

project: PAWS.xcodeproj
schemes:
- PAWS
targets:
- PAWS
- PAWSTests
- PAWSUITests
4 changes: 0 additions & 4 deletions PAWS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
2FE5DC4029EDD7EE004B9AB4 /* FeatureFlags.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FE5DC3E29EDD7ED004B9AB4 /* FeatureFlags.swift */; };
2FE5DC4129EDD7EE004B9AB4 /* StorageKeys.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FE5DC3F29EDD7EE004B9AB4 /* StorageKeys.swift */; };
2FE5DC4529EDD7F2004B9AB4 /* Binding+Negate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FE5DC4229EDD7F2004B9AB4 /* Binding+Negate.swift */; };
2FE5DC4629EDD7F2004B9AB4 /* Bundle+Image.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FE5DC4329EDD7F2004B9AB4 /* Bundle+Image.swift */; };
2FE5DC4729EDD7F2004B9AB4 /* CodableArray+RawRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FE5DC4429EDD7F2004B9AB4 /* CodableArray+RawRepresentable.swift */; };
2FE5DC5129EDD7FA004B9AB4 /* PAWSTaskContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FE5DC4B29EDD7FA004B9AB4 /* PAWSTaskContext.swift */; };
2FE5DC6429EDD883004B9AB4 /* SpeziAccount in Frameworks */ = {isa = PBXBuildFile; productRef = 2FE5DC6329EDD883004B9AB4 /* SpeziAccount */; };
Expand Down Expand Up @@ -127,7 +126,6 @@
2FE5DC3E29EDD7ED004B9AB4 /* FeatureFlags.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeatureFlags.swift; sourceTree = "<group>"; };
2FE5DC3F29EDD7EE004B9AB4 /* StorageKeys.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageKeys.swift; sourceTree = "<group>"; };
2FE5DC4229EDD7F2004B9AB4 /* Binding+Negate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Binding+Negate.swift"; sourceTree = "<group>"; };
2FE5DC4329EDD7F2004B9AB4 /* Bundle+Image.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Bundle+Image.swift"; sourceTree = "<group>"; };
2FE5DC4429EDD7F2004B9AB4 /* CodableArray+RawRepresentable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CodableArray+RawRepresentable.swift"; sourceTree = "<group>"; };
2FE5DC4B29EDD7FA004B9AB4 /* PAWSTaskContext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PAWSTaskContext.swift; sourceTree = "<group>"; };
2FE5DCAC29EE6107004B9AB4 /* AccountOnboarding.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountOnboarding.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -285,7 +283,6 @@
children = (
2FE5DC4229EDD7F2004B9AB4 /* Binding+Negate.swift */,
2FCC1DCA2B6A2B2700C686BE /* Date+RawRepresentable.swift */,
2FE5DC4329EDD7F2004B9AB4 /* Bundle+Image.swift */,
B28A0DDB2BA4AEDE0068258D /* Date+Bool.swift */,
2FE5DC4429EDD7F2004B9AB4 /* CodableArray+RawRepresentable.swift */,
B2433E1C2BCF60C800D7C798 /* Contact+PersonNameComponents.swift */,
Expand Down Expand Up @@ -589,7 +586,6 @@
A9720E432ABB68CC00872D23 /* AccountSetupHeader.swift in Sources */,
2FE5DC4029EDD7EE004B9AB4 /* FeatureFlags.swift in Sources */,
B2F7F1DC2BA53F6400BE93BE /* InvitationCodeView.swift in Sources */,
2FE5DC4629EDD7F2004B9AB4 /* Bundle+Image.swift in Sources */,
2FFD22FC2B59AED8005DD268 /* FAQ.swift in Sources */,
2F4E23832989D51F0013F3D9 /* PAWSTestingSetup.swift in Sources */,
2FE5DC5129EDD7FA004B9AB4 /* PAWSTaskContext.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions PAWS/ECGRecordings/ECGModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import UserNotifications

@Observable
class ECGModule: Module, DefaultInitializable, EnvironmentAccessible {
// periphery:ignore - The ConfigureFirebaseApp injection is required to enforce an initialization within Spezi before this module.
@ObservationIgnored @Dependency(ConfigureFirebaseApp.self) private var firebaseConfiguration
@ObservationIgnored @Dependency(HealthKit.self) private var healthKit

Expand Down
26 changes: 0 additions & 26 deletions PAWS/ECGRecordings/HKElectrocardiogram+SupplementaryData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,6 @@ extension HKElectrocardiogram {
}
}

private func precedingSamples(
forType type: HKSampleType,
sortDescriptors: [SortDescriptor<HKSample>] = [SortDescriptor(\.startDate)],
limit: Int? = nil
) async throws -> [HKSample] {
let store = HKHealthStore()
let queryDescriptor = HKSampleQueryDescriptor(
predicates: [.sample(type: type, predicate: self.fiveMinutePredicate)],
sortDescriptors: sortDescriptors,
limit: limit
)

// If something is available in last 5 minutes since recording, return those samples.
if let result = try? await queryDescriptor.result(for: store), !result.isEmpty {
return result
}

// Otherwise, request the last 24 hours of samples.
let extendedQueryDescriptor = HKSampleQueryDescriptor(
predicates: [.sample(type: type, predicate: self.oneDayPredicate)],
sortDescriptors: sortDescriptors,
limit: limit
)

return try await extendedQueryDescriptor.result(for: store)
}

private func precedingSamples(
forType type: HKQuantityType,
Expand Down
30 changes: 0 additions & 30 deletions PAWS/Helper/Bundle+Image.swift

This file was deleted.

2 changes: 0 additions & 2 deletions PAWS/Helper/FHIRTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@ import ModelsR4

typealias FHIRObservation = ModelsR4.Observation
typealias FHIRResourceProxy = ModelsR4.ResourceProxy
typealias FHIRObservationComponent = ModelsR4.ObservationComponent
typealias FHIRCoding = ModelsR4.Coding
1 change: 0 additions & 1 deletion PAWS/Onboarding/AccountOnboarding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import SwiftUI


struct AccountOnboarding: View {
@Environment(Account.self) private var account
@Environment(OnboardingNavigationPath.self) private var onboardingNavigationPath


Expand Down
1 change: 1 addition & 0 deletions PAWS/Onboarding/Consent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import SwiftUI
/// - Note: The `OnboardingConsentView` exports the signed consent form as PDF to the Spezi `Standard`, necessitating the conformance of the `Standard` to the `OnboardingConstraint`.
struct Consent: View {
@Environment(OnboardingNavigationPath.self) private var onboardingNavigationPath
// periphery:ignore - The periphery warning here is a false positive, the value us stored using @AppStorage.
@AppStorage(StorageKeys.healthKitStartDate) var healthKitStartDate: Date?


Expand Down
20 changes: 13 additions & 7 deletions PAWS/PAWSStandard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import SpeziOnboarding
import SwiftUI


actor PAWSStandard: Standard, EnvironmentAccessible, HealthKitConstraint, ConsentConstraint {
actor PAWSStandard: Standard, EnvironmentAccessible, HealthKitConstraint, ConsentConstraint, AccountNotifyConstraint {
// periphery:ignore - The ConfigureFirebaseApp injection is required to enforce an initialization within Spezi before this module.
@Dependency(ConfigureFirebaseApp.self) private var firebaseConfiguration
@Dependency(ECGModule.self) private var ecgStorage

Expand Down Expand Up @@ -60,12 +61,17 @@ actor PAWSStandard: Standard, EnvironmentAccessible, HealthKitConstraint, Consen


// MARK: - AccountNotifyConstraint
func deletedAccount() async throws {
do {
// delete all user associated data
try await Firestore.firestore().userDocumentReference.delete()
} catch {
logger.error("Could not delete user document: \(error)")
func respondToEvent(_ event: AccountNotifications.Event) async {
switch event {
case .deletingAccount:
do {
// delete all user associated data
try await Firestore.firestore().userDocumentReference.delete()
} catch {
logger.error("Could not delete user document: \(error)")
}
default:
break
}
}

Expand Down
2 changes: 0 additions & 2 deletions PAWS/SharedContext/StorageKeys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ enum StorageKeys {
// MARK: - Onboarding
/// A `Bool` flag indicating of the onboarding was completed.
static let onboardingFlowComplete = "onboardingFlow.complete"
/// A `Step` flag indicating the current step in the onboarding process.
static let onboardingFlowStep = "onboardingFlow.step"


// MARK: - Home
Expand Down
3 changes: 2 additions & 1 deletion PAWS/Study Information/EnrollmentGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import SwiftUI

@Observable
class EnrollmentGroup: Module, EnvironmentAccessible {
@ObservationIgnored @Dependency(ConfigureFirebaseApp.self) private var configureFirebaseApp
// periphery:ignore - The ConfigureFirebaseApp injection is required to enforce an initialization within Spezi before this module.
@ObservationIgnored @Dependency(ConfigureFirebaseApp.self) private var firebaseConfiguration
private var dateOfBirth: Date? {
didSet {
recalcualteStudyGroup()
Expand Down
2 changes: 2 additions & 0 deletions fastlane/SnapshotHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// the new SnapshotHelper.swift
// -----------------------------------------------------

// periphery:ignore:all

import Foundation
import XCTest

Expand Down

0 comments on commit 2cedcb6

Please sign in to comment.