Skip to content

Init design doc#53

Open
rootandroo wants to merge 1 commit into
mainfrom
api-match-history
Open

Init design doc#53
rootandroo wants to merge 1 commit into
mainfrom
api-match-history

Conversation

@rootandroo

Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@sonarqubecloud

Copy link
Copy Markdown

@rootandroo rootandroo marked this pull request as ready for review July 11, 2026 16:01
@rootandroo rootandroo requested a review from a team as a code owner July 11, 2026 16:01
@graphite-app graphite-app Bot requested review from Arshadul-Monir and arklian July 11, 2026 16:01
Comment on lines +33 to +34
WHERE c.run_at >= TIMESTAMPTZ '2026-01-01'
AND c.run_at < TIMESTAMPTZ '2027-01-01';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The SQL query uses hardcoded dates '2026-01-01' and '2027-01-01' instead of parameterizing the {year} path variable. If implemented as written, the endpoint will ignore the year parameter and always return matches for 2026 only.

Fix: Replace with parameterized dates:

WHERE c.run_at >= TIMESTAMPTZ :year || '-01-01'
  AND c.run_at <  TIMESTAMPTZ (:year + 1) || '-01-01'
Suggested change
WHERE c.run_at >= TIMESTAMPTZ '2026-01-01'
AND c.run_at < TIMESTAMPTZ '2027-01-01';
WHERE c.run_at >= TIMESTAMPTZ :year || '-01-01'
AND c.run_at < TIMESTAMPTZ (:year + 1) || '-01-01';

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@graphite-app

graphite-app Bot commented Jul 11, 2026

Copy link
Copy Markdown

Graphite Automations

"Request reviewers once CI passes" took an action on this PR • (07/11/26)

2 reviewers were added to this PR based on Henry Chen's automation.

SELECT m.id, m.member_a_id, m.member_b_id, m.status,
to_char(c.run_at, 'YYYY-MM') AS month
FROM matches m
JOIN match_cycles c ON m.cycle_id = c.id

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

change match_cycle.id to an int

```
* Figured a flat list is more flexible for rendering instead of grouping by month server side

## /api/matches/{year}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just have /api/matches/{match_cycle.id} instead of a year.

Comment on lines +37 to +46
## /api/matches/{year}/{month}
* Join on match_cycles, filtered by run_at within month
```sql
SELECT m.id, m.member_a_id, m.member_b_id, m.status,
to_char(c.run_at, 'YYYY-MM') AS month
FROM matches m
JOIN match_cycles c ON m.cycle_id = c.id
WHERE c.run_at >= TIMESTAMPTZ '2026-01-01'
AND c.run_at < TIMESTAMPTZ '2026-02-01';
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No need to break this up by year


| Method | Path | Description |
|--------|------|-------------|
| GET | /api/matches/{year} | List pairings by year |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should have a /api/matches/list endpoint that takes in search params

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants