Challenge Overview
Create a new model to store project estimate and populate it during project creation.
Project Background
Topcoder Project Service is the main backend service of the Topcode Connect — client facing application of Topcoder.
Recently, we introduced a new feature for Connect app to calculate project scope estimation when customers create a new project. As of now, the project estimation is just front end calculation that we show during project creation and we don't store it in the data store which makes it difficult to see what was the estimate we offered to the customer at the time of project creation. We would like to store the information regarding the price/time estimate.
Technology Stack
-
Node.js
-
PostgreSQL
Code access
The work for this challenge has to be done in one repository:
- Project Service repo https://github.com/topcoder-platform/tc-project-service branch dev commit c321f5092180c1448da4129a9d301c24148eceff or later.
- Config to run Project Service locally is provided on the forum.
Individual requirements
1. Create a new ProjectEsitmation model
-
Create a model:
- id bigint primary key,
- buildingBlockKey: string not null,
- conditions: string not null,
- price: double not null,
- minTime: int not null,
- maxTime: int not null,
- metdata: json default {},
- projectId: bigint not null,
- createdAt/updatedAt/createdBy/updatedBy - standard audit properties -
Create a migration script in /migrations folder to create the corresponding table in the DB.
2. Update create project endpoint
-
Add a new optional property estimation to the create project endpoint payload. Here is an example of the new project create request with "estimation" property https://codeshare.io/24BD3d.
-
This estimation property should accept an array of JSONs with the next properties:
- buildingBlockKey
- conditions
- price
- minTime
- maxTime
- metdata -
Validatie each of these properties using Joi as per model: type of the field and required/optional.
-
If estimation is defined in the create project request: for each of the objects inside this array we should create a new record of ProjectEsitmation.
-
Don’t save this data to ES index, only to DB.
-
Add a unit test which would check, that when we create a project with estimation defined, new ProjectEsitmation records are created.
General requirements
-
Update Swagger file to reflect the changes.
-
Existent unit tests should pass.
-
Lint should pass.