Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: cosa65 <[email protected]>
  • Loading branch information
cosa65 committed Nov 28, 2023
1 parent f9a6758 commit 866bb19
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/api.v2/controllers/sampleFileController.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ const beginUpload = async (req, res) => {

const patchFile = async (req, res) => {
const {
params: { experimentId, sampleId, sampleFileType },
params: { experimentId, sampleFileId },
body: { uploadStatus },
} = req;
logger.log(`Patching file ${sampleFileType} for sample ${sampleId} in experiment ${experimentId}`);
logger.log(`Patching file ${sampleFileId} in experiment ${experimentId}`);

await new SampleFile().updateUploadStatus(sampleId, sampleFileType, uploadStatus);
await new SampleFile().updateUploadStatus(sampleFileId, uploadStatus);

logger.log(`Finished patching sample file for experiment ${experimentId}, sample ${sampleId}, sampleFileType ${sampleFileType}`);
logger.log(`Finished patching sample file for experiment ${experimentId}, file: ${sampleFileId}`);
res.json(OK());
};

Expand Down
12 changes: 3 additions & 9 deletions src/api.v2/model/SampleFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,10 @@ class SampleFile extends BasicModel {
return files;
}

async updateUploadStatus(sampleId, sampleFileType, uploadStatus) {
await this.sql({ sf: tableNames.SAMPLE_FILE })
async updateUploadStatus(sampleFileId, uploadStatus) {
return this.sql({ sf: tableNames.SAMPLE_FILE })
.update({ upload_status: uploadStatus })
.whereExists(
this.sql({ sf_map: tableNames.SAMPLE_TO_SAMPLE_FILE_MAP })
.select(['sample_file_id'])
.where('sf_map.sample_file_id', '=', this.sql.ref('sf.id'))
.where('sf_map.sample_id', '=', sampleId),
)
.andWhere({ sample_file_type: sampleFileType });
.where({ id: sampleFileId });
}
}

Expand Down
11 changes: 3 additions & 8 deletions src/specs/api.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1574,9 +1574,9 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/HTTPError"
"/experiments/{experimentId}/sampleFiles/{sampleFileId}":
patch:
summary: Update a sample files property
description: Update property of a sample file
operationId: patchFile
x-eov-operation-id: sampleFile#patch
x-eov-operation-handler: routes/sampleFile
Expand All @@ -1587,13 +1587,7 @@ paths:
description: ID of the experiment.
schema:
type: string
- name: sampleId
in: path
description: ID of the sample.
required: true
schema:
type: string
- name: sampleFileType
- name: sampleFileId
in: path
description: Type of the file.
required: true
Expand Down Expand Up @@ -1641,6 +1635,7 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/HTTPError"

"/experiments/{experimentId}/sampleFiles/{sampleFileId}/beginUpload":
post:
summary: Begins the multipart upload of a sample file
Expand Down

0 comments on commit 866bb19

Please sign in to comment.