Skip to content

Commit

Permalink
Merge pull request #644 from hpi-studyu/fix/study-duplicate
Browse files Browse the repository at this point in the history
fix: duplicate study missing intervention & measurement data
  • Loading branch information
ibrahimozkn authored Jun 14, 2024
2 parents bb1b638 + f1b96f5 commit 02111ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions designer_v2/lib/repositories/api_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class StudyUApiClient extends SupabaseClientDependant
'study_ended_count',
'active_subject_count',
'contact',
'created_at',
];

static final studyWithParticipantActivityColumns = [
Expand Down
11 changes: 11 additions & 0 deletions designer_v2/lib/repositories/study_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ class StudyRepository extends ModelRepository<Study>
return publishOperation.execute();
}

/// This method fetches the full study object, duplicates it and saves it as a draft.
/// Since the Study object in the dashboard is fetched with limited columns (no intervention or measurement data),
/// we need to fetch the full columns in order to duplicate it correctly.
@override
Future<void> duplicateAndSave(Study model) async {
final Study completeModel = await apiClient.fetchStudy(model.id);
final duplicate =
completeModel.duplicateAsDraft(authRepository.currentUser!.id);
await save(duplicate);
}

@override
List<ModelAction> availableActions(Study model) {
Future<void> onDeleteCallback() {
Expand Down

0 comments on commit 02111ac

Please sign in to comment.