Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
941ba01
README
jmgasper Aug 21, 2025
32b7da8
Updated for real hourly report collation
jmgasper Aug 22, 2025
f731898
Build setup
jmgasper Aug 25, 2025
14e5bc4
Health check endpoint
jmgasper Aug 26, 2025
0841f17
Route and health check cleanup
jmgasper Aug 26, 2025
bae429c
Add back in scope guards
jmgasper Aug 29, 2025
51d3ae5
Tweak endpoints for Topgear - let's keep them in their own sub-path
jmgasper Aug 29, 2025
09edd72
Updates paths and fix build to include SQL
jmgasper Aug 29, 2025
d5a82f5
Better SQL file handling for deployment
jmgasper Aug 29, 2025
f69762f
Tweaks for speed up in dev
jmgasper Aug 29, 2025
b7064ab
Optimisation to fit under 10 seconds
jmgasper Aug 30, 2025
fcc8f37
Fix Swagger path
jmgasper Aug 30, 2025
d5e78f1
PM-1110 - sfdc payment report
vas3a Sep 1, 2025
d494b7d
re-enable auth guards
vas3a Sep 1, 2025
c682486
Use sql file to report sfdc payments
vas3a Sep 2, 2025
fefa60c
PM-1114 - BA fees report
vas3a Sep 2, 2025
42c63c2
Merge pull request #1 from topcoder-platform/PM-1110_sfdc_payment_report
jmgasper Sep 2, 2025
cec45e6
Merge pull request #2 from topcoder-platform/PM-1114_report-ba-fee
jmgasper Sep 2, 2025
7355639
Merge pull request #3 from topcoder-platform/PM-1110_sfdc_payment_report
jmgasper Sep 2, 2025
15c92b9
Updated scopes definition
jmgasper Sep 3, 2025
2401e6d
add exclude billing account filter for sfdc payment report
vas3a Sep 3, 2025
34865ee
use right operator
vas3a Sep 3, 2025
9dd3c5a
fix typo in ba-fees report
vas3a Sep 3, 2025
3bdfaf6
Merge pull request #5 from topcoder-platform/typo-fix
vas3a Sep 3, 2025
9fa1620
Remove ApiQuery from controllers
vas3a Sep 3, 2025
d48185d
Merge pull request #6 from topcoder-platform/fix-swagger
vas3a Sep 3, 2025
d3d0a74
Sfdc reports: make startDate mandatory
vas3a Sep 3, 2025
a98d1ce
Merge pull request #4 from topcoder-platform/add-exclude-filter-sfdc-…
jmgasper Sep 3, 2025
571d6c2
Updates for schema changes
jmgasper Sep 12, 2025
44b4003
Merge branch 'develop' of github.com:topcoder-platform/reports-api-v6…
jmgasper Sep 12, 2025
8173d5d
Topgear challenge report (PM-1132)
jmgasper Sep 15, 2025
6e71743
Add cancelled challenge Topgear endpoint
jmgasper Sep 15, 2025
5f9427b
Scope update
jmgasper Sep 15, 2025
d71fa07
PM-1120 - add endpoint for challenge registrants history report
vas3a Sep 24, 2025
97377c4
Update m2m scope for challenge registrant history endpoint
vas3a Sep 24, 2025
9b1784c
PM-1119 - challenge history report
vas3a Sep 24, 2025
e1dffc1
fix registrant response DTO
vas3a Sep 24, 2025
8ac223b
feat: submission links report
hentrymartin Sep 24, 2025
1a66eda
Merge pull request #7 from topcoder-platform/PM-1120_registrant-histo…
vas3a Sep 25, 2025
6c658b2
Merge pull request #8 from topcoder-platform/PM-1119_challenge-histor…
vas3a Sep 25, 2025
c9aabcb
fix: query
hentrymartin Sep 25, 2025
3714994
fix: query
hentrymartin Sep 25, 2025
6018705
feat: challenge to technology report
hentrymartin Sep 26, 2025
610d24e
fix: lint
hentrymartin Sep 26, 2025
dfd1547
fix: report name
hentrymartin Sep 26, 2025
9e9718a
fix: report name
hentrymartin Sep 26, 2025
deaa41d
Merge pull request #10 from topcoder-platform/pm-1128
jmgasper Sep 26, 2025
f5be234
feat: topgear challenge registration report
hentrymartin Sep 29, 2025
89a4702
feat: topgear challenge registration report
hentrymartin Sep 29, 2025
d5ad26a
feat: topgear app winner badges report
hentrymartin Sep 29, 2025
b211bcc
feat: topgear app winner badges report
hentrymartin Sep 29, 2025
2d2baf0
fix: added specific scope for new service endpoint
hentrymartin Sep 29, 2025
7a46b60
fix: unified the report
hentrymartin Sep 30, 2025
5b41921
fix: removed unused sql file
hentrymartin Sep 30, 2025
68e8016
Merge pull request #9 from topcoder-platform/pm-1259
hentrymartin Sep 30, 2025
42c892a
Merge pull request #11 from topcoder-platform/pm-1130
hentrymartin Sep 30, 2025
1890c33
increase report limit
vas3a Oct 1, 2025
b3412a9
Merge pull request #13 from topcoder-platform/increase-report-limit
vas3a Oct 1, 2025
4d057ee
fix: include v6 urls for CORS
hentrymartin Oct 1, 2025
4bd281e
fix: lint
hentrymartin Oct 1, 2025
4b22b66
Merge pull request #14 from topcoder-platform/fix-submission-links-query
hentrymartin Oct 1, 2025
95429fe
fix: debug
hentrymartin Oct 2, 2025
1ac8f5a
fix: debug
hentrymartin Oct 2, 2025
5eeaebe
fix: debug
hentrymartin Oct 2, 2025
da7e810
fix: debug
hentrymartin Oct 2, 2025
89b9b58
fix: debug
hentrymartin Oct 2, 2025
6b62a10
fix: debug
hentrymartin Oct 2, 2025
84fcc11
fix: debug
hentrymartin Oct 2, 2025
a977127
fix: debug
hentrymartin Oct 2, 2025
c94b4be
Merge pull request #15 from topcoder-platform/pm-1259_1
hentrymartin Oct 2, 2025
8cc97bd
updated from develop
hentrymartin Oct 2, 2025
99377f6
add review buddy
kkartunov Oct 3, 2025
aebd702
fix: submission link to date query and registrants details sql
hentrymartin Oct 5, 2025
f30ebf8
fix: submission link to date query and registrants details sql
hentrymartin Oct 5, 2025
630603c
fix: submission link to date query and registrants details sql
hentrymartin Oct 5, 2025
7147685
fix: submission link to date query and registrants details sql
hentrymartin Oct 5, 2025
80eda32
fix: submission link to date query and registrants details sql
hentrymartin Oct 5, 2025
d60b831
Merge pull request #16 from topcoder-platform/pm-1259_2
hentrymartin Oct 5, 2025
35edde8
Merge pull request #12 from topcoder-platform/pm-1127
hentrymartin Oct 6, 2025
f1380c1
fix: query issue with topgear reports
hentrymartin Oct 8, 2025
a82d364
Merge pull request #17 from topcoder-platform/pm-1127_1
hentrymartin Oct 8, 2025
fa5f349
Statistics updates
jmgasper Oct 8, 2025
1477b9b
Merge
jmgasper Oct 8, 2025
85d5da3
Updated statistics for design
jmgasper Oct 8, 2025
21be65a
updated swagger docs
hentrymartin Oct 9, 2025
e81a664
Merge pull request #18 from topcoder-platform/update-swagger-docs
hentrymartin Oct 9, 2025
bb727bf
Update query
jmgasper Oct 9, 2025
18385d5
Merge branch 'develop' of github.com:topcoder-platform/reports-api-v6…
jmgasper Oct 9, 2025
469fac9
Additional reports for statistics page
jmgasper Oct 9, 2025
ebbfc6a
Static marathon match endpoints for now TODO: tie these into real data
jmgasper Oct 9, 2025
3ed5f70
Use correct abbreviations for design track
jmgasper Oct 9, 2025
c5f81e8
Better compatibility with existing stats page
jmgasper Oct 9, 2025
adda2d0
Updates to additional design reports - will have to test these in pro…
jmgasper Oct 9, 2025
83852d0
Additional statistics endpoints for the remaining development and qa …
jmgasper Oct 9, 2025
160eebf
Fix up challenge tech report ad add in rux placements
jmgasper Oct 10, 2025
a221c9b
Major cleanup to perfectly match Looker fields so we have to do less …
jmgasper Oct 10, 2025
ed145fb
Pnpm lock file
jmgasper Oct 10, 2025
9c5d66e
default country
jmgasper Oct 10, 2025
b4b7fd1
Fix up first time design submitters
jmgasper Oct 10, 2025
be05a2a
Fix up wireframe wins
jmgasper Oct 10, 2025
fc6706c
Update to add challenge ID to payments response, per Topgear request
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
76 changes: 76 additions & 0 deletions .circleci/config.yml
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

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.

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 repository without verifying the integrity of the scripts can pose a security risk. Consider adding a mechanism to verify the authenticity of the scripts, such as checking a hash or using a signed tag.

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 .

Choose a reason for hiding this comment

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

[⚠️ performance]
Using --no-cache=true in Docker builds can lead to longer build times. Ensure this is necessary for your use case, as caching can significantly improve performance.

- 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

Choose a reason for hiding this comment

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

[💡 style]
The file lacks a newline at the end, which is a common convention for text files. Consider adding a newline to improve compatibility with various tools and editors.

13 changes: 13 additions & 0 deletions .editorconfig
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

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 adhere to POSIX standards and improve compatibility with various tools.

36 changes: 36 additions & 0 deletions Dockerfile
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

Choose a reason for hiding this comment

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

[⚠️ maintainability]
Installing pnpm globally in multiple stages (deps and build) may lead to inconsistencies if different versions are installed. Consider using a specific version or consolidating the installation to a single stage.

# Copy dependency-defining files
COPY package.json pnpm-lock.yaml ./
# Install dependencies
RUN pnpm install --frozen-lockfile --prod

Choose a reason for hiding this comment

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

[💡 correctness]
Using --frozen-lockfile ensures that the exact versions in pnpm-lock.yaml are installed, which is good for consistency. However, ensure that the lockfile is up-to-date with package.json to avoid potential issues.


# ---- 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

Choose a reason for hiding this comment

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

[⚠️ performance]
Copying the entire data directory from the build stage to production may include unnecessary files. Ensure that only required files are included to optimize the image size.

# 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"]
90 changes: 90 additions & 0 deletions README.md
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.
Loading