Challenge Overview
Challenge Objectives
-
Update the logic behind the challenge phases based on the requirements below.
Tech Stack
-
Node.js
-
Swagger
-
DynamoDB
-
ElasticSearch
Project Background
In this series of challenges, we will build the version 5 (V5) of the challenge API.
Code Access
Challenge API
Repo: https://github.com/topcoder-platform/challenge-api
Branch: develop
Challenge Processor ES
Repo: https://github.com/topcoder-platform/challenge-processor-es
Branch: develop
You may also have to run the Resources API locally https://github.com/topcoder-platform/resources-api (develop branch)
Detailed requirements
As part of this challenge, you need to make the following changes on the challenge API, the ES processor as well as the legacy challenge migration script:
-
Both apps: Rename the `isActive` property to `isOpen`.
-
Challenge API: Create a new model that will be used to associate ChallengeTypes with TimelineTemplates. Create CRUD endpoints (/challengeTimelines) for that new model. For READ, we just need `get all` with support for filtering based on the challenge type ID or timeline template ID.
-
Challenge API: Remove the `predecessor` property from the Phase model and update all related endpoints. This property should only exist in phases associated with a challenge (Challenge.phases). Add a new `typeId` property (required) which is an auto-generated UUID.
-
Challenge API: Update all related endpoints that create/update challenge phases (phases that belong to a challenge) so only the `typeId` and the duration are passed and all other fields are populated/calculated by the API. You also need to update all existing validation that currently happens for phases.
-
Challenge API: In the phase object that’s associated with a challenge (Challenge.phases), we need to keep the `predecessor` property that was removed (above requirement) and we also need to add a few new properties.
1. typeId which is a required UUID. Get it from the actual phase definition.
2. scheduledStartDate which is a required date (String) and it’s being calculated based on the challenge start date and the duration of each phase.
3. scheduledEndDate which is a required date (String) and it’s being calculated based on the challenge start date and the duration of each phase.
4. actualStartDate and actualEndDate that currently behave similarly to the scheduledStartDate/scheduledEndDate fields.
Create a helper method similar to the Helper.calculateChallengeEndDate to help you calculate the start/end dates. -
Challenge API: Update the TimelineTemplate and all related endpoints so the phases array is an array of objects and each object has the following properties:
typeId: Required UUID, should match to the typeId of an existing phase
predecessor: Optional UUID, should match to the id of an existing phase
defaultDuration: Required integer representing the phase duration in seconds. -
Both apps: The phase duration should be saved in seconds and not in hours. If we have any specific calculations/restrictions, update them to be in seconds instead of hours.
-
Challenge API: When creating/updating a challenge (for the update, only if the phases are actually being updated), use the TimelineTempate ID to get the TimelineTemplate and use it to set the `predecessor` property of each phase. Also, if the duration of a phase is not provided, use the `defaultDuration` from the timeline template.
-
ES Processor: Make sure to update the processor to reflect all the above changes.
-
Make sure to update the Swagger as well as the POSTMAN collection to reflect all changes.
-
Update existing tests to pass and make sure to cover all new code with tests.
Should you have any questions, feel free to ask on the challenge forum!
What to Submit
Submit a git patch file for the latest commit in the develop branch of each repo.
Make sure to mention the exact commit you used so we can apply your patch without issues.