-
Notifications
You must be signed in to change notification settings - Fork 0
syncing dev to master #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
941ba01
32b7da8
f731898
14e5bc4
0841f17
bae429c
51d3ae5
09edd72
d5a82f5
f69762f
b7064ab
fcc8f37
d5e78f1
d494b7d
c682486
fefa60c
42c63c2
cec45e6
7355639
15c92b9
2401e6d
34865ee
9dd3c5a
3bdfaf6
9fa1620
d48185d
d3d0a74
a98d1ce
571d6c2
44b4003
8173d5d
6e71743
5f9427b
d71fa07
97377c4
9b1784c
e1dffc1
8ac223b
1a66eda
6c658b2
c9aabcb
3714994
6018705
610d24e
dfd1547
9e9718a
deaa41d
f5be234
89a4702
d5ad26a
b211bcc
2d2baf0
7a46b60
5b41921
68e8016
42c892a
1890c33
b3412a9
4d057ee
4bd281e
4b22b66
95429fe
1ac8f5a
5eeaebe
da7e810
89b9b58
6b62a10
84fcc11
a977127
c94b4be
8cc97bd
99377f6
aebd702
f30ebf8
630603c
7147685
80eda32
d60b831
35edde8
f1380c1
a82d364
fa5f349
1477b9b
85d5da3
21be65a
e81a664
bb727bf
18385d5
469fac9
ebbfc6a
3ed5f70
c5f81e8
adda2d0
83852d0
160eebf
a221c9b
ed145fb
9c5d66e
b4b7fd1
be05a2a
fc6706c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| version: 2.1 | ||
|
|
||
| defaults: &defaults | ||
| docker: | ||
| - image: cimg/python:3.13.2-browsers | ||
| install_dependency: &install_dependency | ||
| name: Installation of build and deployment dependencies. | ||
| command: | | ||
| sudo apt update | ||
| sudo apt install -y jq python3-pip | ||
| sudo 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [❗❗ |
||
| cp ./../buildscript/master_deploy.sh . | ||
| cp ./../buildscript/buildenv.sh . | ||
| cp ./../buildscript/awsconfiguration.sh . | ||
| cp ./../buildscript/psvar-processor.sh . | ||
|
|
||
| builddeploy_steps: &builddeploy_steps | ||
| - checkout | ||
| - setup_remote_docker | ||
| - run: *install_dependency | ||
| - run: *install_deploysuite | ||
| - run: docker buildx build --no-cache=true -t ${APPNAME}:latest . | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| - 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 | ||
|
|
||
| jobs: | ||
| # Build & Deploy against development backend | ||
| "build-dev": | ||
| !!merge <<: *defaults | ||
| environment: | ||
| DEPLOY_ENV: "DEV" | ||
| LOGICAL_ENV: "dev" | ||
| APPNAME: "reports-api-v6" | ||
| DEPLOYMENT_ENVIRONMENT: 'dev' | ||
| steps: *builddeploy_steps | ||
|
|
||
| "build-prod": | ||
| !!merge <<: *defaults | ||
| environment: | ||
| DEPLOY_ENV: "PROD" | ||
| LOGICAL_ENV: "prod" | ||
| APPNAME: "reports-api-v6" | ||
| DEPLOYMENT_ENVIRONMENT: 'prod' | ||
| 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 | ||
| - pm-1127_1 | ||
|
|
||
| # Production builds are exectuted only on tagged commits to the | ||
| # master branch. | ||
| - "build-prod": | ||
| context: org-global | ||
| filters: | ||
| branches: | ||
| only: | ||
| - master | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [💡 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # EditorConfig is awesome: https://EditorConfig.org | ||
|
|
||
| # top-most EditorConfig file | ||
| root = true | ||
|
|
||
| [*] | ||
| indent_style = space | ||
| indent_size = 2 | ||
| end_of_line = lf | ||
| charset = utf-8 | ||
| trim_trailing_whitespace = true | ||
| insert_final_newline = true | ||
|
|
| 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [💡 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # ---- Base Stage ---- | ||
| FROM node:20-alpine AS base | ||
| WORKDIR /usr/src/app | ||
|
|
||
| # ---- Dependencies Stage ---- | ||
| FROM base AS deps | ||
| # Install pnpm | ||
| RUN npm install -g pnpm | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| # Copy dependency-defining files | ||
| COPY package.json pnpm-lock.yaml ./ | ||
| # Install dependencies | ||
| RUN pnpm install --frozen-lockfile --prod | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [💡 |
||
|
|
||
| # ---- Build Stage ---- | ||
| FROM base AS build | ||
| RUN npm install -g pnpm | ||
| COPY --from=deps /usr/src/app/node_modules ./node_modules | ||
| COPY . . | ||
| # Build the application | ||
| RUN pnpm build | ||
|
|
||
| # ---- Production Stage ---- | ||
| FROM base AS production | ||
| ENV NODE_ENV production | ||
| # Copy built application from the build stage | ||
| COPY --from=build /usr/src/app/dist ./dist | ||
| COPY --from=build /usr/src/app/sql ./sql | ||
| COPY --from=build /usr/src/app/data ./data | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| # Copy production dependencies from the deps stage | ||
| COPY --from=deps /usr/src/app/node_modules ./node_modules | ||
|
|
||
| # Expose the application port | ||
| EXPOSE 3000 | ||
|
|
||
| # The command to run the application | ||
| CMD ["node", "dist/main.js"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| ## Description | ||
|
|
||
| This repository houses the reports API for all Topcoder and Topgear reports on the Topcoder platform. The reports are pulled directly from live data, not a data warehouse, so they should be up-to-date when they are generated and the response is returned. | ||
|
|
||
| All reports will return JSON data with the expected fields for the individual report | ||
|
|
||
| ## Security | ||
|
|
||
| Currently, an M2M token is required to pull any report, and each report has its own scope associated with it that must be applied to the M2M token client ID | ||
|
|
||
| ## Layout | ||
|
|
||
| Each report will be a separate SQL query, potentially with a few parameters (like a start and an end date, for example). The individual SQL queries can be found in the `sql` folder and should be able to be run against the `topcoder-services` RDS database in dev or prod, with minimal changes to replace the parameters. | ||
|
|
||
| ## Technology Stack | ||
|
|
||
| - **Framework**: NestJS | ||
| - **Language**: TypeScript | ||
| - **Database**: PostgreSQL | ||
| - **ORM**: Prisma | ||
| - **Package Manager**: pnpm | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Node.js (v22 or later recommended) | ||
| - pnpm | ||
|
|
||
| ## Getting Started | ||
|
|
||
| ### 1. Clone the Repository | ||
|
|
||
| ```bash | ||
| git clone <repository-url> | ||
| cd reports-api-v6 | ||
| ``` | ||
|
|
||
| ### 2. Install Dependencies | ||
|
|
||
| This project uses pnpm as the package manager. Ensure you have it installed, then run: | ||
|
|
||
| ```bash | ||
| pnpm install | ||
| ``` | ||
| ### 4. Configure Environment Variables | ||
|
|
||
| Create a `.env` file in the root of the project. You can copy the example structure below. The default values are configured to work with the local Docker setup. | ||
|
|
||
| ```bash | ||
| # .env | ||
|
|
||
| # PostgreSQL Database URL for Prisma | ||
| # This is used by Prisma to connect to your local PostgreSQL instance. | ||
| DATABASE_URL="postgresql://user:password@localhost:5432/lookups?schema=public" | ||
|
|
||
| # --------------------------------------------------- | ||
| # JWT Authentication Secrets | ||
| # These are used by tc-core-library-js for validating JWTs. | ||
| # --------------------------------------------------- | ||
|
|
||
| # The secret key used to sign and verify JWTs. | ||
| AUTH_SECRET="mysecret" | ||
|
|
||
| # A JSON array string of valid token issuers. | ||
| VALID_ISSUERS='["https://topcoder-dev.auth0.com/","https://api.topcoder.com"]' | ||
|
|
||
| ## Running the Application | ||
|
|
||
| ### Development Mode | ||
|
|
||
| To run the application in development mode with hot-reloading: | ||
|
|
||
| ```bash | ||
| pnpm run dev | ||
| ``` | ||
|
|
||
| The application will be available at http://localhost:3000. | ||
|
|
||
| ## Public Statistics Endpoints | ||
|
|
||
| The following read-only endpoints are available without authentication to support the Community Statistics page. | ||
|
|
||
| - `GET /v6/reports/statistics/srm/top-rated` — Highest rated SRM data (static JSON) | ||
| - `GET /v6/reports/statistics/srm/country-ratings` — SRM country ratings (static JSON) | ||
| - `GET /v6/reports/statistics/srm/competitions-count` — SRM number of competitions (static JSON) | ||
| - `GET /v6/reports/statistics/mm/top-rated` — Highest rated Marathon Match data (static JSON) | ||
| - `GET /v6/reports/statistics/mm/country-ratings` — Marathon Match country ratings (static JSON) | ||
| - `GET /v6/reports/statistics/mm/top-10-finishes` — Marathon Match Top 10 finishes (static JSON) | ||
| - `GET /v6/reports/statistics/mm/competitions-count` — Marathon Match number of competitions (static JSON) | ||
|
|
||
| Static datasets are stored under `data/statistics/srm` and `data/statistics/mm` and are packaged into the ECS image in the Dockerfile. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[⚠️
maintainability]Consider using a virtual environment for Python dependencies instead of installing globally with
sudo pip3 install. This improves maintainability and avoids potential conflicts with system packages.