From 3c14ef69f660ee4774f3ecc8b8588ecb9c48ee74 Mon Sep 17 00:00:00 2001
From: Angelina Uno-Antonison <ange.unoantonison@gmail.com>
Date: Tue, 5 Dec 2023 15:37:02 -0600
Subject: [PATCH] wip to get things together

---
 backend/src/routers/analysis_router.py          |  3 +++
 .../tests/integration/test_analysis_routers.py  |  2 +-
 frontend/src/models/analyses.js                 | 17 ++++++++++++++++-
 frontend/src/views/AnalysisView.vue             |  4 ++--
 4 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/backend/src/routers/analysis_router.py b/backend/src/routers/analysis_router.py
index a667fe45..ab62a89c 100644
--- a/backend/src/routers/analysis_router.py
+++ b/backend/src/routers/analysis_router.py
@@ -84,14 +84,17 @@ def get_genomic_units(analysis_name: str, repositories=Depends(database)):
     except ValueError as exception:
         raise HTTPException(status_code=404, detail=str(exception)) from exception
 
+
 @router.get("/{analysis_name}/summary", response_model=AnalysisSummary)
 def get_analysis_summary_by_name(analysis_name: str, repositories=Depends(database)):
     """Returns a summary of every analysis within the application"""
     return repositories["analysis"].summary_by_name(analysis_name)
 
+
 @router.put("/{analysis_name}/event/{event_type}", response_model=Analysis)
 def update_event(
     analysis_name: str,
+    event_type: EventType,
     repositories=Depends(database),
     username: VerifyUser = Security(get_current_user),
     authorized=Security(get_authorization, scopes=["write"]),  #pylint: disable=unused-argument
diff --git a/backend/tests/integration/test_analysis_routers.py b/backend/tests/integration/test_analysis_routers.py
index 77e0d76e..ce001fc9 100644
--- a/backend/tests/integration/test_analysis_routers.py
+++ b/backend/tests/integration/test_analysis_routers.py
@@ -83,7 +83,7 @@ def test_import_analysis_with_phenotips_json(
     assert response_data['timeline'][0]['username'] == 'johndoe'
 
 
-def test_update_analysis_section(client, mock_access_token, mock_repositories, update_analysis_section_response_json):
+def test_update_analysis_sections(client, mock_access_token, mock_repositories, update_analysis_section_response_json):
     """Testing if the update analysis endpoint updates an existing analysis"""
 
     updated_sections = [{
diff --git a/frontend/src/models/analyses.js b/frontend/src/models/analyses.js
index a97d78de..af85c313 100644
--- a/frontend/src/models/analyses.js
+++ b/frontend/src/models/analyses.js
@@ -31,6 +31,15 @@ export default {
     return genomicUnits;
   },
 
+  /**
+   * Provides {@link updatedSections} of updated text fields within sections in
+   * the analysis {@link analysisName}.
+   * @param {string} analysisName The unique name of the Analysis to update
+   * @param {Object} updatedSections The list of updated fields from within
+   *                                 their corresponding sections
+   * @return {Object[]} Array of all of the sections, including the updated
+   * ones, within the Analysis
+   */
   async updateAnalysisSections(analysisName, updatedSections) {
     const sectionsToUpdate = [];
     for (const [sectionName, field] of Object.entries(updatedSections)) {
@@ -63,8 +72,14 @@ export default {
     return annotationRenderingTemporary;
   },
 
+  /**
+   * Requests to upload the JSON required for creating a new analysis in Rosalution
+   * with a unique analysis name.
+   * @param {File} file The JSON for creating the new Analysis
+   * @return {Object} Returns the new complete analysis created within Rosalution
+   */
   async importPhenotipsAnalysis(file) {
-    const url = '/rosalution/api/analysisfup';
+    const url = '/rosalution/api/analysis';
 
     const fileUploadFormData = {
       'phenotips_file': file,
diff --git a/frontend/src/views/AnalysisView.vue b/frontend/src/views/AnalysisView.vue
index 147a9d2c..77824e70 100644
--- a/frontend/src/views/AnalysisView.vue
+++ b/frontend/src/views/AnalysisView.vue
@@ -405,12 +405,12 @@ export default {
       );
     },
     async saveAnalysisChanges() {
-      const updatedAnalysis = await Analyses.updateAnalysisSections(
+      const updatedSections = await Analyses.updateAnalysisSections(
           this.analysis_name,
           this.updatedContent,
       );
       this.analysis.sections.splice(0);
-      this.analysis.sections.push(...updatedAnalysis.sections);
+      this.analysis.sections.push(...updatedSections);
       location.reload();
       this.updatedContent = {};
       this.edit = false;