Skip to content

Commit 170867d

Browse files
1. Remove typeId and filename for artifacts - use file's name itself as the artifact name
2. Prevent sort by name for review type (text field cannot be sorted in ES)
1 parent c0fc850 commit 170867d

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed

docs/swagger.yaml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -469,17 +469,7 @@ paths:
469469
name: artifact
470470
type: file
471471
required: true
472-
description: Artifact to be uploaded
473-
- in: formData
474-
name: typeId
475-
required: true
476-
type: string
477-
example: 'c56a4180-65aa-42ec-a945-5fd21dec0503'
478-
- in: formData
479-
name: filename
480-
required: true
481-
type: string
482-
example: 'genericFilename'
472+
description: Artifact to be uploaded. Pass the name of the artifact along with the data
483473
responses:
484474
200:
485475
description: Artifact created successfully
@@ -1781,7 +1771,7 @@ parameters:
17811771
fileParam:
17821772
name: file
17831773
in: path
1784-
description: artifact id
1774+
description: artifact id (its filename)
17851775
required: true
17861776
type: string
17871777

src/services/ArtifactService.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function * createArtifact (files, submissionId, entity) {
8989
logger.info('Creating a new Artifact')
9090
if (files && files.artifact) {
9191
const uFileType = fileTypeFinder(files.artifact.data).ext // File type of uploaded file
92-
fileName = `${submissionId}/${entity.filename}.${uFileType}`
92+
fileName = `${submissionId}/${files.artifact.name}.${uFileType}`
9393
let exist
9494
// Check the existence of file in S3 bucket
9595
try {
@@ -100,7 +100,7 @@ function * createArtifact (files, submissionId, entity) {
100100
}
101101

102102
if (exist) {
103-
throw new errors.HttpStatusError(409, `Artifact ${entity.filename}.${uFileType} already exists for Submission ${submissionId}`)
103+
throw new errors.HttpStatusError(409, `Artifact ${files.artifact.name}.${uFileType} already exists for Submission ${submissionId}`)
104104
}
105105
// Upload the artifact to S3
106106
yield _uploadToS3(files.artifact, fileName)
@@ -113,10 +113,7 @@ function * createArtifact (files, submissionId, entity) {
113113
createArtifact.schema = {
114114
files: joi.any().required(),
115115
submissionId: joi.string().guid().required(),
116-
entity: joi.object().keys({
117-
typeId: joi.string().uuid().required(),
118-
filename: joi.string().required()
119-
}).required()
116+
entity: joi.object()
120117
}
121118

122119
/**

src/services/ReviewTypeService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const listReviewTypesQuerySchema = {
6767

6868
listReviewTypesQuerySchema.sortBy = joi.string().valid(_.difference(
6969
Object.keys(listReviewTypesQuerySchema),
70-
['page', 'perPage', 'orderBy']
70+
['page', 'perPage', 'orderBy', 'name']
7171
))
7272

7373
listReviewTypes.schema = {

0 commit comments

Comments
 (0)