Challenge Overview
Crete a script for seeding a demo data for local development purposes.
Project Background
Topcoder Project Serice is the main backend service of the Topcode Connect - client facing application of Topcoder.
Currently, when we run Project Service locally for developing purpose we have to use Postman to create a demo data to work with. As there are already a lot of entities in Project Service, creating demo data manually takes time so we want to create a script which will seed demo data.
Technology Stack
-
Node.js
-
PostgreSQL
-
ElastiSearch
Code access
The work for this challenge has to be done in one repository https://github.com/topcoder-platform/tc-project-service dev branch.
You would have to verify that demo data works well by running Connect App locally https://github.com/appirio-tech/connect-app dev branch.
Individual requirements
Create a seed script which will create 7 projects.
-
The script and related files should be placed into local/seed folder.
-
This script should be called by ‘npm run seed’
-
We already have seedMetadata script which copies metadata from Topcoder DEV environment to local deployment.
- move it to local/seed folder
- reuse it inside the new seed script (you may modify it to be able to call it from the new script)
- this script will create most of the data which we need to create projects -
Seed script should create 7 projects:
- create json files with data for projects, don’t copy them from dev as it’s done for metadata
- to be able to create projects you would need to populate some dependent data like projectTypes - create json file for them also
- all the demo data should be created by calling Project Service API endpoints rather than writing to DB directly, same like it’s done for metadata. The only difference, instead of getting data from the DEV environment we prepare json files. -
So the overall script will look like this:
- call seedMetadata script to populate metdata
- populate the rest of dependant entities like projectTypes
- populate 7 projects with different statuses https://github.com/topcoder-platform/tc-project-service/blob/feature/fix-metadata-seed-script/src/constants.js#L1 Also, please use different sets of members for each of these projects. -
Note: use Postman collection to understand what demo data can look like.
General requirements
-
At the moment we only need demo data which is enough to see the list of the project and go to project details pages.
-
Test that demo data works well by running Connect App locally https://github.com/topcoder-platform/tc-project-service#run-connect-app-with-project-service-locally
-
We have two ways of running Project Service locally:
- using local mock-service to mock Identity and Member services
- using Identity and Member services deployed to Topcoder DEV environment
Our demo data should work well when we run project service locally both ways. To achieve this, we have to only use users who are listed in https://github.com/topcoder-platform/tc-project-service/blob/feature/fix-metadata-seed-script/local/mock-services/services.json#L2 as these users are present in both DEV environment and our mock service.
- test that demo data works in both ways of deploying Project Service with M2M token provided and without. Other words when we run project service with each of these config files config/mock.local.js and config/m2m.local.js. -
Lint and unit tests should be passed.
-
Update README to reflect a new command of creating demo data.