diff --git a/internal/dataagreement_record/db.go b/internal/dataagreement_record/db.go index 6a39da9..1a5afbf 100644 --- a/internal/dataagreement_record/db.go +++ b/internal/dataagreement_record/db.go @@ -203,22 +203,6 @@ func CreatePipelineForFilteringDataAgreementRecords(organisationId string, id st return pipeline, nil } -// Deletes all the data agreement records for data agreement id -func (darRepo *DataAgreementRecordRepository) DeleteDataAgreementRecordsForDataAgreement(dataAgreementId string) error { - filter := common.CombineFilters(darRepo.DefaultFilter, bson.M{"dataagreementid": dataAgreementId}) - - // Update to set IsDeleted to true - update := bson.M{ - "$set": bson.M{ - "isdeleted": true, - }, - } - - _, err := Collection().UpdateMany(context.TODO(), filter, update) - - return err -} - // CreatePipelineForFilteringLatestDataAgreementRecords This pipeline is used for filtering data agreement records func CreatePipelineForFilteringLatestDataAgreementRecords(organisationId string) ([]primitive.M, error) { diff --git a/internal/handler/v2/config/dataagreement/config_delete_dataagreement.go b/internal/handler/v2/config/dataagreement/config_delete_dataagreement.go index 3b2cfdc..e54334f 100644 --- a/internal/handler/v2/config/dataagreement/config_delete_dataagreement.go +++ b/internal/handler/v2/config/dataagreement/config_delete_dataagreement.go @@ -44,14 +44,6 @@ func ConfigDeleteDataAgreement(w http.ResponseWriter, r *http.Request) { darRepo := daRecord.DataAgreementRecordRepository{} darRepo.Init(organisationId) - // Deletes all the data agreement records for data agreement id - err = darRepo.DeleteDataAgreementRecordsForDataAgreement(dataAgreementId) - if err != nil { - m := fmt.Sprintf("Failed to delete data agreement id from data agreement records: %v", dataAgreementId) - common.HandleErrorV2(w, http.StatusInternalServerError, m, err) - return - } - _, err = daRepo.Update(currentDataAgreement) if err != nil { m := fmt.Sprintf("Failed to delete data agreement: %v", dataAgreementId) diff --git a/internal/handler/v2/service/service_update_dataagreement_record.go b/internal/handler/v2/service/service_update_dataagreement_record.go index 56b15cb..8e28446 100644 --- a/internal/handler/v2/service/service_update_dataagreement_record.go +++ b/internal/handler/v2/service/service_update_dataagreement_record.go @@ -57,6 +57,17 @@ func ServiceUpdateDataAgreementRecord(w http.ResponseWriter, r *http.Request) { common.HandleErrorV2(w, http.StatusInternalServerError, m, err) return } + // Repository + daRepo := dataagreement.DataAgreementRepository{} + daRepo.Init(organisationId) + + da, err := daRepo.Get(dataAgreementId) + if err != nil { + m := fmt.Sprintf("Failed to fetch data agreement: %v", dataAgreementId) + common.HandleErrorV2(w, http.StatusInternalServerError, m, err) + return + } + // Repository darRepo := daRecord.DataAgreementRecordRepository{} darRepo.Init(organisationId) @@ -104,17 +115,6 @@ func ServiceUpdateDataAgreementRecord(w http.ResponseWriter, r *http.Request) { return } - // Repository - daRepo := dataagreement.DataAgreementRepository{} - daRepo.Init(organisationId) - - da, err := daRepo.Get(dataAgreementId) - if err != nil { - m := fmt.Sprintf("Failed to fetch data agreement: %v", dataAgreementId) - common.HandleErrorV2(w, http.StatusInternalServerError, m, err) - return - } - // Trigger webhooks var consentedAttributes []string for _, pConsent := range da.DataAttributes {