Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Run image:
`docker run -p 3000:3000 -i -t -e DB_HOST=172.17.0.1 tc_projects_services`
You may replace 172.17.0.1 with your docker0 IP.

You can paste **swagger.yaml** to [swagger editor](http://editor.swagger.io/) or import **postman.json** to verify endpoints.
You can paste **swagger.yaml** to [swagger editor](http://editor.swagger.io/) or import **postman.json** and **postman_environment.json** to verify endpoints.

#### Deploying without docker
If you don't want to use docker to deploy to localhost. You can simply run `npm run start` from root of project. This should start the server on default port `3000`.
6 changes: 5 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@
},
"analyticsKey": "",
"VALID_ISSUERS": "[\"https:\/\/topcoder-newauth.auth0.com\/\",\"https:\/\/api.topcoder-dev.com\"]",
"busApiUrl": "http://api.topcoder-dev.com",
"validIssuers": "[\"https:\/\/topcoder-newauth.auth0.com\/\",\"https:\/\/api.topcoder-dev.com\"]",
"jwksUri": "",
"busApiUrl": "http://api.topcoder-dev.com/v5",
"busApiToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoicHJvamVjdC1zZXJ2aWNlIiwiaWF0IjoxNTEyNzQ3MDgyLCJleHAiOjE1MjEzODcwODJ9.PHuNcFDaotGAL8RhQXQMdpL8yOKXxjB5DbBIodmt7RE",
"HEALTH_CHECK_URL": "_health",
"maxPhaseProductCount": 1,
"AUTH0_CLIENT_ID": "",
"AUTH0_CLIENT_SECRET": "",
"AUTH0_AUDIENCE": "",
Expand Down
2 changes: 1 addition & 1 deletion local/mock-services/authMiddleware.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = function def(req, res, next) {
if (req.method === 'POST' && req.url === '/authorizations/') {
if (req.method === 'POST' && (req.url === '/authorizations/' || req.url === '/authorizations')) {
const resp = {
id: '1',
result: {
Expand Down
5 changes: 3 additions & 2 deletions local/mock-services/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ server.use(authMiddleware);
// add additional search route for project members
server.get('/v3/members/_search', (req, res) => {
const fields = _.isString(req.query.fields) ? req.query.fields.split(',') : [];
const filter = _.isString(req.query.query) ? req.query.query.split(' OR ') : [];
const filter = _.isString(req.query.query) ?
req.query.query.replace('%2520', ' ').replace('%20', ' ').split(' OR ') : [];
const criteria = _.map(filter, (single) => {
const ret = { };
const ret = {};
const splitted = single.split(':');
// if the result can be parsed successfully
const parsed = jsprim.parseInteger(splitted[1], { allowTrailing: true, trimWhitespace: true });
Expand Down
150 changes: 150 additions & 0 deletions local/mock-services/services.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,156 @@
}
},
"version": "v3"
},
{
"id": "test_customer1",
"result": {
"success": true,
"status": 200,
"metadata": null,
"content": {
"maxRating": {
"rating": 1114,
"track": "DATA_SCIENCE",
"subTrack": "SRM"
},
"createdBy": "40011578",
"updatedBy": "40011578",
"userId": 40051331,
"firstName": "Firstname",
"lastName": "Lastname",
"quote": "It is a mistake to think you can solve any major problems just with potatoes.",
"description": null,
"otherLangName": null,
"handle": "test_customer1",
"handleLower": "test_customer1",
"status": "ACTIVE",
"email": "test_customer1@email.com",
"addresses": [
{
"streetAddr1": "100 Main Street",
"streetAddr2": "",
"city": "Chicago",
"zip": "60601",
"stateCode": "IL",
"type": "HOME",
"updatedAt": null,
"createdAt": null,
"createdBy": null,
"updatedBy": null
}
],
"homeCountryCode": "USA",
"competitionCountryCode": "USA",
"photoURL": null,
"tracks": [
"DEVELOP"
],
"updatedAt": "2015-12-02T14:00Z",
"createdAt": "2014-04-10T10:55Z"
}
},
"version": "v3"
},
{
"id": "test_copilot1",
"result": {
"success": true,
"status": 200,
"metadata": null,
"content": {
"maxRating": {
"rating": 1114,
"track": "DATA_SCIENCE",
"subTrack": "SRM"
},
"createdBy": "40011578",
"updatedBy": "40011578",
"userId": 40051332,
"firstName": "Firstname",
"lastName": "Lastname",
"quote": "It is a mistake to think you can solve any major problems just with potatoes.",
"description": null,
"otherLangName": null,
"handle": "test_copilot1",
"handleLower": "test_copilot1",
"status": "ACTIVE",
"email": "test_copilot1@email.com",
"addresses": [
{
"streetAddr1": "100 Main Street",
"streetAddr2": "",
"city": "Chicago",
"zip": "60601",
"stateCode": "IL",
"type": "HOME",
"updatedAt": null,
"createdAt": null,
"createdBy": null,
"updatedBy": null
}
],
"homeCountryCode": "USA",
"competitionCountryCode": "USA",
"photoURL": null,
"tracks": [
"DEVELOP"
],
"updatedAt": "2015-12-02T14:00Z",
"createdAt": "2014-04-10T10:55Z"
}
},
"version": "v3"
},
{
"id": "test_manager1",
"result": {
"success": true,
"status": 200,
"metadata": null,
"content": {
"maxRating": {
"rating": 1114,
"track": "DATA_SCIENCE",
"subTrack": "SRM"
},
"createdBy": "40011578",
"updatedBy": "40011578",
"userId": 40051333,
"firstName": "Firstname",
"lastName": "Lastname",
"quote": "It is a mistake to think you can solve any major problems just with potatoes.",
"description": null,
"otherLangName": null,
"handle": "test_manager1",
"handleLower": "test_manager1",
"status": "ACTIVE",
"email": "test_manager1@email.com",
"addresses": [
{
"streetAddr1": "100 Main Street",
"streetAddr2": "",
"city": "Chicago",
"zip": "60601",
"stateCode": "IL",
"type": "HOME",
"updatedAt": null,
"createdAt": null,
"createdBy": null,
"updatedBy": null
}
],
"homeCountryCode": "USA",
"competitionCountryCode": "USA",
"photoURL": null,
"tracks": [
"DEVELOP"
],
"updatedAt": "2015-12-02T14:00Z",
"createdAt": "2014-04-10T10:55Z"
}
},
"version": "v3"
}
]
}
4 changes: 4 additions & 0 deletions migrations/elasticsearch_sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ function getRequestBody(indexName) {
},
},
},
phases: {
type: 'nested',
dynamic: true,
},
},
};
switch (indexName) {
Expand Down
28 changes: 17 additions & 11 deletions migrations/seedElasticsearchIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,21 @@ Promise.coroutine(function* wrapped() {
config.get('pubsubQueueName'),
);


const projectIds = getProjectIds();
const projectWhereClause = (projectIds.length > 0) ? { id: { $in: projectIds } } : { deletedAt: { $eq: null } };
const projects = yield models.Project.findAll({
let projects = yield models.Project.findAll({
where: projectWhereClause,
raw: true,
include: [{
model: models.ProjectPhase,
as: 'phases',
include: [{ model: models.PhaseProduct, as: 'products' }],
}],
});
logger.info(`Retrieved #${projects.length} projects`);

// Convert to raw json
projects = _.map(projects, project => project.toJSON());

const memberWhereClause = (projectIds.length > 0)
? { projectId: { $in: projectIds } }
: { deletedAt: { $eq: null } };
Expand All @@ -59,14 +65,14 @@ Promise.coroutine(function* wrapped() {
promises.push(rabbit.publish('project.initial', p, {}));
});
Promise.all(promises)
.then(() => {
logger.info(`Published ${promises.length} msgs`);
process.exit();
})
.catch((err) => {
logger.error(err);
process.exit();
});
.then(() => {
logger.info(`Published ${promises.length} msgs`);
process.exit();
})
.catch((err) => {
logger.error(err);
process.exit();
});
} catch (err) {
logger.error(err);
process.exit();
Expand Down
Loading