Skip to content

Commit ef403c5

Browse files
Model updates
1 parent 7194575 commit ef403c5

16 files changed

+33
-510
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ You can find sample `.env` files inside the `/docs` directory.
7676
2. Creating tables: `npm run create-tables`
7777
3. Seed/Insert data to tables: `npm run seed-tables`
7878
4. Initialize/Clear database in default environment: `npm run init-db`
79-
5. View table data in default environment: `npm run view-data <ModelName>`, ModelName can be `Challenge`, `ChallengeType`, `ChallengeMetadata`, `AuditLog`, `Phase`, `TimelineTemplate`or `Attachment`
79+
5. View table data in default environment: `npm run view-data <ModelName>`, ModelName can be `Challenge`, `ChallengeType`, `AuditLog`, `Phase`, `TimelineTemplate`or `Attachment`
8080
6. Create Elasticsearch index: `npm run init-db`, or to re-create index: `npm run init-db force`
8181
7. Synchronize ES data and DynamoDB data: `npm run sync-es`
8282

Verification.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- You need to run command `npm run sync-es` before you run `Challenges/get challenge` and `Challenges/search challenge` test case.
88

99
## DynamoDB Verification
10-
Run command `npm run view-data <ModelName>` to view table data, ModelName can be `Challenge`, `ChallengeType`, `ChallengeMetadata`, `AuditLog`, `Phase`, `TimelineTemplate`, `Attachment` or `ChallengeTypeTimelineTemplate`
10+
Run command `npm run view-data <ModelName>` to view table data, ModelName can be `Challenge`, `ChallengeType`, `AuditLog`, `Phase`, `TimelineTemplate`, `Attachment` or `ChallengeTypeTimelineTemplate`
1111

1212
## S3 Verification
1313

app-constants.js

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ const Topics = {
3030
ChallengeUpdated: 'challenge.notification.update',
3131
ChallengeTypeCreated: 'test.new.bus.events', // 'challenge.action.type.created',
3232
ChallengeTypeUpdated: 'test.new.bus.events', // 'challenge.action.type.updated',
33-
ChallengeMetadataCreated: 'test.new.bus.events', // 'challenge.action.metdata.created',
34-
ChallengeMetadataUpdated: 'test.new.bus.events', // 'challenge.action.metadata.updated',
3533
ChallengePhaseCreated: 'test.new.bus.events', // 'challenge.action.phase.created',
3634
ChallengePhaseUpdated: 'test.new.bus.events', // 'challenge.action.phase.updated',
3735
ChallengePhaseDeleted: 'test.new.bus.events', // 'challenge.action.phase.deleted',

app-routes.js

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ module.exports = (app) => {
5353
next()
5454
}
5555
} else {
56+
console.log(req.authUser)
5657
req.authUser.userId = String(req.authUser.userId)
5758
// User roles authorization
5859
if (req.authUser.roles) {

config/default.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,6 @@ module.exports = {
7575
DELETE: process.env.SCOPE_CHALLENGE_TYPE_TIMELINE_TEMPLATES_DELETE || 'delete:challenge_type_timeline_templates',
7676
ALL: process.env.SCOPE_CHALLENGE_TYPE_TIMELINE_TEMPLATES_ALL || 'all:challenge_type_timeline_templates'
7777
},
78-
CHALLENGE_METADATA: {
79-
READ: process.env.SCOPE_CHALLENGE_METADATA_READ || 'read:challenge_metadata',
80-
CREATE: process.env.SCOPE_CHALLENGE_METADATA_CREATE || 'create:challenge_metadata',
81-
UPDATE: process.env.SCOPE_CHALLENGE_METADATA_UPDATE || 'update:challenge_metadata',
82-
ALL: process.env.SCOPE_CHALLENGE_METADATA_ALL || 'all:challenge_metadata'
83-
},
8478
CHALLENGE_AUDIT_LOGS: {
8579
READ: process.env.SCOPE_CHALLENGE_AUDIT_LOGS_READ || 'read:challenge_audit_logs'
8680
},
@@ -105,5 +99,7 @@ module.exports = {
10599
}
106100
},
107101

102+
DEFAULT_CONFIDENTIALITY_TYPE: process.env.DEFAULT_CONFIDENTIALITY_TYPE || 'public',
103+
108104
M2M_AUDIT_HANDLE: process.env.M2M_AUDIT_HANDLE || 'TopcoderService'
109105
}

docs/swagger.yaml

+3-225
Original file line numberDiff line numberDiff line change
@@ -650,209 +650,6 @@ paths:
650650
description: Server error
651651
schema:
652652
$ref: '#/definitions/ErrorModel'
653-
/challenge-metadata:
654-
get:
655-
tags:
656-
- ChallengeMetadata
657-
description: |
658-
Retrieve challenge settings in the system.
659-
security:
660-
- bearer: []
661-
produces:
662-
- application/json
663-
parameters:
664-
- $ref: '#/parameters/page'
665-
- $ref: '#/parameters/perPage'
666-
- name: name
667-
in: query
668-
description: Filter by name, case-insensitive, partial matches are allowed.
669-
required: false
670-
type: string
671-
responses:
672-
'200':
673-
description: OK
674-
schema:
675-
type: array
676-
items:
677-
$ref: '#/definitions/ChallengeMetadata'
678-
headers:
679-
X-Next-Page:
680-
type: integer
681-
description: The index of the next page
682-
X-Page:
683-
type: integer
684-
description: The index of the current page (starting at 1)
685-
X-Per-Page:
686-
type: integer
687-
description: The number of items to list per page
688-
X-Prev-Page:
689-
type: integer
690-
description: The index of the previous page
691-
X-Total:
692-
type: integer
693-
description: The total number of items
694-
X-Total-Pages:
695-
type: integer
696-
description: The total number of pages
697-
Link:
698-
type: string
699-
description: Pagination link header.
700-
'400':
701-
description: Bad request. Request parameters were invalid.
702-
schema:
703-
$ref: '#/definitions/ErrorModel'
704-
'401':
705-
description: Unauthorized. Fail to authenticate the requester.
706-
schema:
707-
$ref: '#/definitions/ErrorModel'
708-
'403':
709-
description: >
710-
Forbidden. The requester does not have the correct permission to
711-
access the challenge setting
712-
schema:
713-
$ref: '#/definitions/ErrorModel'
714-
'500':
715-
description: Server error
716-
schema:
717-
$ref: '#/definitions/ErrorModel'
718-
post:
719-
tags:
720-
- ChallengeChallengeMetadataSettings
721-
description: |
722-
Create a new challenge setting in the system.
723-
security:
724-
- bearer: []
725-
produces:
726-
- application/json
727-
parameters:
728-
- in: body
729-
name: body
730-
required: true
731-
schema:
732-
$ref: '#/definitions/ChallengeMetadataData'
733-
responses:
734-
'201':
735-
description: Created - The request was successful and the resource is returned.
736-
schema:
737-
$ref: '#/definitions/ChallengeMetadata'
738-
'400':
739-
description: Bad request. Request parameters were invalid.
740-
schema:
741-
$ref: '#/definitions/ErrorModel'
742-
'401':
743-
description: Unauthorized. Fail to authenticate the requester.
744-
schema:
745-
$ref: '#/definitions/ErrorModel'
746-
'403':
747-
description: >
748-
Forbidden. The requester does not have the correct permission to
749-
create the challenge settings
750-
schema:
751-
$ref: '#/definitions/ErrorModel'
752-
'409':
753-
description: >
754-
Conflict. Other challenge setting has already used the same name.
755-
schema:
756-
$ref: '#/definitions/ErrorModel'
757-
'500':
758-
description: Server error
759-
schema:
760-
$ref: '#/definitions/ErrorModel'
761-
'/challenge-metadata/:challengeMetadataId':
762-
get:
763-
tags:
764-
- ChallengeMetadata
765-
description: Retrieve the Challenge settings with provided challenge settings id.
766-
security:
767-
- bearer: []
768-
produces:
769-
- application/json
770-
parameters:
771-
- name: challengeMetadataId
772-
in: path
773-
required: true
774-
type: string
775-
format: UUID
776-
description: The id of challenge settings to retrieve
777-
responses:
778-
'200':
779-
description: OK
780-
schema:
781-
$ref: '#/definitions/ChallengeMetadata'
782-
'400':
783-
description: Bad request. Request parameters were invalid.
784-
schema:
785-
$ref: '#/definitions/ErrorModel'
786-
'401':
787-
description: Unauthorized. Fail to authenticate the requester.
788-
schema:
789-
$ref: '#/definitions/ErrorModel'
790-
'403':
791-
description: >
792-
Forbidden. The requester does not have the correct permission to
793-
access the challenge setting
794-
schema:
795-
$ref: '#/definitions/ErrorModel'
796-
'404':
797-
description: Challenge setting not found
798-
schema:
799-
$ref: '#/definitions/ErrorModel'
800-
'500':
801-
description: Server error
802-
schema:
803-
$ref: '#/definitions/ErrorModel'
804-
put:
805-
tags:
806-
- ChallengeMetadata
807-
description: Update the challenge settings with the specified id.
808-
security:
809-
- bearer: []
810-
produces:
811-
- application/json
812-
parameters:
813-
- name: challengeMetadataId
814-
in: path
815-
required: true
816-
type: string
817-
format: UUID
818-
description: The id of ChallengeMetadata to update
819-
- in: body
820-
name: body
821-
required: true
822-
schema:
823-
$ref: '#/definitions/ChallengeMetadataData'
824-
responses:
825-
'200':
826-
description: Updated - The request was successful and the resource is returned.
827-
schema:
828-
$ref: '#/definitions/ChallengeMetadata'
829-
'400':
830-
description: Bad request. Request parameters were invalid.
831-
schema:
832-
$ref: '#/definitions/ErrorModel'
833-
'401':
834-
description: Unauthorized. Fail to authenticate the requester.
835-
schema:
836-
$ref: '#/definitions/ErrorModel'
837-
'403':
838-
description: >
839-
Forbidden. The requester does not have the correct permission to
840-
update the challenge setting
841-
schema:
842-
$ref: '#/definitions/ErrorModel'
843-
'404':
844-
description: Challenge setting not found
845-
schema:
846-
$ref: '#/definitions/ErrorModel'
847-
'409':
848-
description: >
849-
Conflict. Other challenge setting has already used the same name.
850-
schema:
851-
$ref: '#/definitions/ErrorModel'
852-
'500':
853-
description: Server error
854-
schema:
855-
$ref: '#/definitions/ErrorModel'
856653
/challenge-phases:
857654
get:
858655
tags:
@@ -1915,18 +1712,6 @@ definitions:
19151712
- $ref: '#/definitions/ChallengeTypeData'
19161713
required:
19171714
- id
1918-
ChallengeMetadata:
1919-
type: object
1920-
allOf:
1921-
- type: object
1922-
properties:
1923-
id:
1924-
type: string
1925-
description: The challenge settings id.
1926-
format: UUID
1927-
- $ref: '#/definitions/ChallengeMetadataData'
1928-
required:
1929-
- id
19301715
Phase:
19311716
type: object
19321717
allOf:
@@ -1982,11 +1767,11 @@ definitions:
19821767
privateDescription:
19831768
type: string
19841769
description: returned only if the user is registered on the challenge.
1985-
ChallengeMetadata:
1770+
metadata:
19861771
type: array
19871772
items:
19881773
properties:
1989-
type:
1774+
name:
19901775
type: string
19911776
description: The challenge setting type
19921777
example: 'challenge setting name'
@@ -2140,13 +1925,6 @@ definitions:
21401925
- name
21411926
- isActive
21421927
- abbreviation
2143-
ChallengeMetadataData:
2144-
type: object
2145-
properties:
2146-
name:
2147-
type: string
2148-
required:
2149-
- name
21501928
PhaseData:
21511929
type: object
21521930
properties:
@@ -2381,7 +2159,7 @@ definitions:
23812159
type: array
23822160
items:
23832161
properties:
2384-
type:
2162+
name:
23852163
type: string
23862164
description: The challenge setting type
23872165
format: UUID

src/controllers/ChallengeMetadataController.js

-54
This file was deleted.

src/init-db.js

-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ const initDB = async () => {
1616
for (const challenge of challenges) {
1717
await challenge.delete()
1818
}
19-
const settings = await helper.scan('ChallengeMetadata')
20-
for (const setting of settings) {
21-
await setting.delete()
22-
}
2319
const typeTimelineTemplates = await helper.scan('ChallengeTypeTimelineTemplate')
2420
for (const typeTT of typeTimelineTemplates) {
2521
await typeTT.delete()

0 commit comments

Comments
 (0)