Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
b69b341
Update Code with Postgres Schema Part 2 Final Fix
NoisyLanius Jul 13, 2025
b10735e
Add Postman collection
NoisyLanius Jul 13, 2025
632531c
Merge pull request #2 from NoisyLanius/develop
jmgasper Jul 14, 2025
0cdbfd6
circleci config changes
Gunasekar-K Jul 22, 2025
94dfc80
circleci config changes
Gunasekar-K Jul 22, 2025
ecc2bc7
version change
Gunasekar-K Jul 24, 2025
36ed70c
add stats and history endpoints
stevenfrog Jul 27, 2025
e70c080
fix patch stats bug
stevenfrog Jul 27, 2025
1939008
migrage dynamo data
stevenfrog Aug 8, 2025
5d77a1e
Merge pull request #3 from stevenfrog/stats-and-history-apis
jmgasper Aug 11, 2025
68cb0c7
Merge branch 'develop' into migrate-dynamo-data
jmgasper Aug 11, 2025
62949da
Merge pull request #4 from stevenfrog/migrate-dynamo-data
jmgasper Aug 11, 2025
428580f
add subTrackId in DataScienceHistory schema
stevenfrog Aug 14, 2025
3b0f267
Merge pull request #5 from stevenfrog/add-subtrackid-in-data-science-…
jmgasper Aug 14, 2025
5c82c28
Add migration for new subtrackID field
Aug 14, 2025
c533f3f
update trait data list item type
phead1987 Sep 3, 2025
3aea18b
Merge pull request #7 from topcoder-platform/issue/phead/6
jmgasper Sep 3, 2025
42da375
submit codes
stevenfrog Sep 6, 2025
a187616
Merge pull request #8 from stevenfrog/distribution-fix
jmgasper Sep 6, 2025
12c8a90
Add member handle autocomplete, similar to v3 endpoint that is used i…
jmgasper Sep 19, 2025
235231d
Updates to Swagger docs for QA
jmgasper Sep 24, 2025
b300d5a
Fix up work and education importing
jmgasper Oct 1, 2025
e3aa240
Allow us to re-run the member traits importer without being destructive
jmgasper Oct 1, 2025
3e3c62f
Fix up industry type import
jmgasper Oct 1, 2025
0752f4a
Member lookup fixes for system admin app
jmgasper Oct 3, 2025
ea8cc3b
add review buddy
kkartunov Oct 3, 2025
dc84442
Fixes for account-settings (PM-2194, 2193)
jmgasper Oct 6, 2025
efc8765
Fix for setting traits and receiving back conflicting errors (PM-2198)
jmgasper Oct 6, 2025
0bfb541
Fixes for saving account settings traits
jmgasper Oct 6, 2025
f5bc335
Update to remove redundant tables and use the skills schema for skill…
jmgasper Oct 6, 2025
7a76ceb
Update skill score calculations for talent-search
jmgasper Oct 6, 2025
22029cd
Skill score application in SQL for better quicker sorting
jmgasper Oct 6, 2025
7dee263
Remove potentially destructive target
jmgasper Oct 11, 2025
29feca5
Updates for migration in prod
jmgasper Oct 14, 2025
153d68d
Split out member and skills schemas into different DB connections
jmgasper Oct 14, 2025
4ae3029
Default for prod migration
jmgasper Oct 20, 2025
b59b0c5
Prod import issue
jmgasper Oct 20, 2025
ab15e40
Updates for prod data
jmgasper Oct 20, 2025
5d613b2
Incremental support for importing migration data
jmgasper Oct 20, 2025
f288fdd
Updates to fix prod issue seen
jmgasper Oct 21, 2025
acc5c04
Better handling of weird values in import data
jmgasper Oct 21, 2025
186cb3b
Prod dirty data fixes
jmgasper Oct 21, 2025
2458186
Fixes for prod data
jmgasper Oct 22, 2025
941ad70
Additiona performance indices
jmgasper Oct 23, 2025
7073bb4
Fix for prod data migration
jmgasper Oct 23, 2025
d1e46cd
Build error fix
jmgasper Oct 23, 2025
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
78 changes: 78 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
version: 2
defaults: &defaults
docker:
- image: cimg/python:3.12.1-browsers
install_dependency: &install_dependency
name: Installation of build and deployment dependencies.
command: |
pip3 install awscli --upgrade
install_deploysuite: &install_deploysuite
name: Installation of install_deploysuite.
command: |
git clone --branch v1.4.19 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ security]
Cloning a specific branch from a public GitHub repository without verifying the integrity of the scripts can introduce security risks. Consider verifying the integrity of the scripts, for example, by checking a hash or using a trusted source.

cp ./../buildscript/master_deploy.sh .
cp ./../buildscript/buildenv.sh .
cp ./../buildscript/awsconfiguration.sh .
cp ./../buildscript/psvar-processor.sh .
restore_cache_settings_for_build: &restore_cache_settings_for_build
key: docker-node-modules-v6-{{ checksum "yarn.lock" }}

save_cache_settings: &save_cache_settings
key: docker-node-modules-v6-{{ checksum "yarn.lock" }}
paths:
- node_modules

builddeploy_steps: &builddeploy_steps
- checkout
- setup_remote_docker
- run: *install_dependency
- run: *install_deploysuite
- run: ./build.sh ${APPNAME}
- run:
name: Running MasterScript.
command: |
./awsconfiguration.sh $DEPLOY_ENV
source awsenvconf
./psvar-processor.sh -t appenv -p /config/${APPNAME}/deployvar
source deployvar_env
./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -j /config/${APPNAME}/appvar,/config/common/global-appvar -i ${APPNAME} -p FARGATE

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ security]
Using environment variables directly in scripts can lead to security issues if they are not properly sanitized or if they contain sensitive information. Ensure that sensitive data is handled securely.

jobs:
# Build & Deploy against development backend
"build-dev":
!!merge <<: *defaults

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The use of !!merge is not a standard YAML feature and may cause issues with some parsers. Consider using a more standard approach to merge YAML anchors.

environment:
DEPLOY_ENV: "DEV"
LOGICAL_ENV: "dev"
APPNAME: "member-api-v6"
steps: *builddeploy_steps

"build-prod":
!!merge <<: *defaults

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The use of !!merge is not a standard YAML feature and may cause issues with some parsers. Consider using a more standard approach to merge YAML anchors.

environment:
DEPLOY_ENV: "PROD"
LOGICAL_ENV: "prod"
APPNAME: "member-api-v6"
steps: *builddeploy_steps

workflows:
version: 2
build:
jobs:
# Development builds are executed on "develop" branch only.
- "build-dev":
context: org-global
filters:
branches:
only:
- develop

# Production builds are exectuted only on tagged commits to the
# master branch.
- "build-prod":
context: org-global
filters:
branches:
only:
- master
22 changes: 22 additions & 0 deletions .github/workflows/code_reviewer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: AI PR Reviewer

on:
pull_request:
types:
- opened
- synchronize
permissions:
pull-requests: write
jobs:
tc-ai-pr-review:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: TC AI PR Reviewer
uses: topcoder-platform/tc-ai-pr-reviewer@master
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # The GITHUB_TOKEN is there by default so you just need to keep it like it is and not necessarily need to add it as secret as it will throw an error. [More Details](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret)
LAB45_API_KEY: ${{ secrets.LAB45_API_KEY }}
exclude: '**/*.json, **/*.md, **/*.jpg, **/*.png, **/*.jpeg, **/*.bmp, **/*.webp' # Optional: exclude patterns separated by commas

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💡 style]
Consider adding a newline at the end of the file to improve compatibility with various tools and editors, which often expect files to end with a newline character.

45 changes: 45 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# can be used locally to config some env variables and after apply them using `source .env`
.env
### Node ###
# Logs
logs
*.log
npm-debug.log*
.DS_Store
.tern-port
*#

dist/

# Runtime data
pids
*.pid
*.seed
AGENTS.md

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm


.DS_Store
.idea
.vscode/
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
21.6

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💡 style]
Consider adding a newline at the end of the file to adhere to POSIX standards, which can improve compatibility with various tools and systems.

21 changes: 11 additions & 10 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ docker run -d --name memberdb -p 5432:5432 \
After that, please set db URL environment variables:
```bash
export DATABASE_URL="postgresql://johndoe:mypassword@localhost:5432/memberdb"
export SKILLS_DB_URL="postgresql://johndoe:mypassword@localhost:5432/skillsdb"
```

This variable is important since it's required by prisma.
These variables are important since they're required by Prisma clients.

If you want to do anything with database, this variable is necessary.
If you want to do anything with database, these variables are necessary.

## Database Scripts

Expand All @@ -33,6 +34,7 @@ Before running db scripts, please make sure you have setup db and config db url
```bash
# set db url values
export DATABASE_URL="postgresql://johndoe:mypassword@localhost:5432/memberdb"
export SKILLS_DB_URL="postgresql://johndoe:mypassword@localhost:5432/skillsdb"

# install dependencies
npm install
Expand Down Expand Up @@ -61,7 +63,7 @@ I have created a script to download data from dev environment and a script to lo
To use them, you should:
- Make sure you have started db.
- Check configs in `src/scripts/config.js`. Add some handle if you like.
- Open a terminal and navigate to codebase folder. Set `DATABASE_URL` above.
- Open a terminal and navigate to codebase folder. Set `DATABASE_URL` and `SKILLS_DB_URL` above.
- Run `npm install`.
- Use `node src/scripts/download.js` to download profile data.
- Run `npm run clear-db` to clear db data first
Expand All @@ -86,7 +88,7 @@ The following parameters can be set in config files or in env variables:
- BUSAPI_URL: Bus API URL
- KAFKA_ERROR_TOPIC: Kafka error topic used by bus API wrapper
- GROUPS_API_URL: Groups API URL
- AMAZON.AWS_ACCESS_KEY_ID: The Amazon certificate key to use when connecting.
- AMAZON.AWS_ACCESS_KEY_ID: The Amazon certificate key to use when connecting.
- AMAZON.AWS_SECRET_ACCESS_KEY: The Amazon certificate access key to use when connecting.
- AMAZON.AWS.SESSION_TOKEN: The user session token, used when developing locally against the TC dev AWS services
- AMAZON.AWS_REGION: The Amazon certificate region to use when connecting.
Expand Down Expand Up @@ -138,6 +140,8 @@ To make local development easier, I create a mock server at `mock`.

You can start it with `node mock/mock-api.js` and it will listen to port `4000`

This mock service will simulate request and responses for other APIs like auth0 and event bus API.

## Local Configs

Please run following commands to set necessary configs:
Expand All @@ -147,13 +151,11 @@ export AUTH0_URL="http://localhost:4000/v5/auth0"
export BUSAPI_URL="http://localhost:4000/v5"
export AUTH0_CLIENT_ID=xyz
export AUTH0_CLIENT_SECRET=xyz
export LOOKER_API_BASE_URL="http://localhost:4000/v5/looker"
export LOOKER_API_CLIENT_ID=xyz
export LOOKER_API_CLIENT_SECRET=xyz
export USERFLOW_PRIVATE_KEY=mysecret
export GROUPS_API_URL="http://localhost:4000/v5/groups"
```

These commands will set auth0, event bus pi and looker api to local mock server.
These commands will set auth0 and event bus api to local mock server.

## Local Deployment

Expand All @@ -167,12 +169,11 @@ These commands will set auth0, event bus pi and looker api to local mock server.
## Tests


Make sure you have followed above steps to
Make sure you have followed above steps to
- setup db and config db url
- setup local mock api and set local configs
- it will really call service and mock api

Unit tests use `aws-sdk-mock` to mock S3 operations. So you can safely run tests without S3 configs.

Then you can run:
```bash
Expand Down
1 change: 1 addition & 0 deletions Verification.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Just be careful about the schemas used for different kind of trait.
There are some changes to prisma schema.

- Add memberTraits.hobby
- Update memberSkill.displayMode to optional
- Remove displayMode.memberSkills @ignore
- Add stats fields as discussed in forum

1 change: 1 addition & 0 deletions app-bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Joi.page = () => Joi.number().integer().min(1).default(1)
Joi.perPage = () => Joi.number().integer().min(1).max(100).default(50)
Joi.size = () => Joi.number().integer().min(1).max(1000).default(500)
Joi.sort = () => Joi.string().default('asc')
Joi.positive = () => Joi.number().integer().min(0)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💡 readability]
Consider renaming Joi.positive to Joi.nonNegative to more accurately reflect that the minimum value is 0, which includes zero as a valid value.

2 changes: 1 addition & 1 deletion app-constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* App constants
*/
const ADMIN_ROLES = ['administrator', 'admin']
const SEARCH_BY_EMAIL_ROLES = ADMIN_ROLES.concat('tgadmin');
const SEARCH_BY_EMAIL_ROLES = ADMIN_ROLES.concat('tgadmin')
const AUTOCOMPLETE_ROLES = ['copilot', 'administrator', 'admin', 'Connect Copilot', 'Connect Account Manager', 'Connect Admin', 'Account Executive']

const EVENT_ORIGINATOR = 'topcoder-member-api'
Expand Down
15 changes: 15 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const HttpStatus = require('http-status-codes')
const logger = require('./src/common/logger')
const interceptor = require('express-interceptor')
const fileUpload = require('express-fileupload')
const path = require('path')
const swaggerUi = require('swagger-ui-express')
const YAML = require('yamljs')

// setup express app
const app = express()
Expand All @@ -35,6 +38,18 @@ app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
app.set('port', config.PORT)

// Swagger / OpenAPI documentation
const swaggerDocument = YAML.load(path.join(__dirname, 'docs', 'swagger.yaml'))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ security]
Loading the Swagger document using YAML.load can be a potential security risk if the YAML file contains untrusted content. Consider using a safer method or validating the content after loading.

swaggerDocument.basePath = `/${config.API_VERSION}`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Directly modifying the basePath of the Swagger document might lead to unexpected behavior if the document is used elsewhere. Ensure that this change is intended and does not affect other parts of the application.

const docsRoute = `/${config.API_VERSION}/members/api-docs`
app.use(docsRoute, swaggerUi.serve, swaggerUi.setup(swaggerDocument, {
swaggerOptions: { docExpansion: 'list' },
customSiteTitle: 'Topcoder Member API v6 Documentation'
}))
app.get(`${docsRoute}.json`, (req, res) => {
res.json(swaggerDocument)
})

// intercept the response body from jwtAuthenticator
app.use(interceptor((req, res) => {
return {
Expand Down
23 changes: 23 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
set -eo pipefail
APP_NAME=$1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
Consider adding a check to ensure APP_NAME is not empty before proceeding. This will prevent potential errors when the script is executed without an argument.

UPDATE_CACHE=""
#docker-compose -f docker/docker-compose.yml build $APP_NAME
docker build -f docker/Dockerfile -t $APP_NAME:latest .
docker create --name app $APP_NAME:latest

if [ -d node_modules ]
then
mv package-lock.json old-package-lock.json
docker cp app:/$APP_NAME/package-lock.json package-lock.json
set +eo pipefail
UPDATE_CACHE=$(cmp package-lock.json old-package-lock.json)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
The use of cmp to compare package-lock.json files will result in UPDATE_CACHE being empty if the files are identical. This could lead to unexpected behavior in the subsequent conditional check. Consider using a more explicit comparison method that sets UPDATE_CACHE to a clear boolean value.

set -eo pipefail
else
UPDATE_CACHE=1
fi

if [ "$UPDATE_CACHE" == 1 ]
then
docker cp app:/$APP_NAME/node_modules .
fi

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💡 style]
Add a newline at the end of the file to adhere to POSIX standards and avoid potential issues with certain text processing tools.

16 changes: 1 addition & 15 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ module.exports = {
}
},


// Member identifiable info fields, copilots, admins, or M2M can get these fields
// Anyone in the constants.AUTOCOMPLETE_ROLES will have access to these fields
COMMUNICATION_SECURE_FIELDS: process.env.COMMUNICATION_SECURE_FIELDS
Expand Down Expand Up @@ -120,20 +119,7 @@ module.exports = {
MAMBO_DOMAIN_URL: process.env.MAMBO_DOMAIN_URL,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
The removal of the LOOKER configuration block could impact functionality if any part of the application relies on Looker API access. Ensure that this removal is intentional and that no dependent code will break due to missing configuration.

MAMBO_DEFAULT_SITE: process.env.MAMBO_DEFAULT_SITE,

// Looker API access config
LOOKER: {
API_BASE_URL: process.env.LOOKER_API_BASE_URL,
API_CLIENT_ID: process.env.LOOKER_API_CLIENT_ID,
API_CLIENT_SECRET: process.env.LOOKER_API_CLIENT_SECRET,
EMBED_KEY: process.env.LOOKER_EMBED_KEY,
HOST: process.env.LOOKER_HOST,
SESSION_LENGTH: 1800,
TOKEN: process.env.LOOKER_API_TOKEN || 'TOKEN',
//24 hours, in milliseconds
CACHE_DURATION: 1000 * 60 * 60 * 24
},

HASHING_KEYS: {
USERFLOW: process.env.USERFLOW_PRIVATE_KEY,
USERFLOW: process.env.USERFLOW_PRIVATE_KEY
}
}
13 changes: 13 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Use the base image with Node.js
FROM node:21.6.0

# Copy the current directory into the Docker image
COPY . /member-api-v6

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ security]
Copying the entire current directory into the Docker image can lead to larger image sizes and potential security risks if sensitive files are included. Consider using a .dockerignore file to exclude unnecessary files and directories.


# Set working directory for future use
WORKDIR /member-api-v6

# Install the dependencies from package.json
RUN yarn

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
Using yarn without specifying --frozen-lockfile can lead to inconsistent dependencies being installed if the yarn.lock file is not up-to-date. Consider using RUN yarn install --frozen-lockfile to ensure consistency.


CMD node app.js

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💡 style]
There is no newline at the end of the file. While this is not a functional issue, it is a common convention to end files with a newline to avoid potential issues with concatenation or certain text processing tools.

Loading