Skip to content

Commit

Permalink
wip to get things together
Browse files Browse the repository at this point in the history
  • Loading branch information
SeriousHorncat committed Dec 5, 2023
1 parent 33151eb commit 3c14ef6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
3 changes: 3 additions & 0 deletions backend/src/routers/analysis_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/integration/test_analysis_routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [{
Expand Down
17 changes: 16 additions & 1 deletion frontend/src/models/analyses.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/views/AnalysisView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3c14ef6

Please sign in to comment.