Skip to content
Open
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ racing/racing
*.out
.idea
.vscode

*.exe
84 changes: 84 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
## Candidate 2 Solution – Usage Guide

This guide explains the features added step‑by‑step so you can try them quickly.

### Step 1: Filter Races by Visibility
You can narrow the list of races to only those marked visible using the optional field `visible_only`.

Field: `filter.visible_only` (boolean, optional)

Behavior:
* Omitted or false → all races returned (original behavior).
* true → only races where `visible` is true.

Endpoint: `POST http://localhost:8000/v1/list-races`

Example – All races
```bash
curl -s -X POST http://localhost:8000/v1/list-races \
-H "Content-Type: application/json" \
-d '{}'
```

Example – Only visible races
```bash
curl -s -X POST http://localhost:8000/v1/list-races \
-H "Content-Type: application/json" \
-d '{"filter":{"visible_only":true}}'
```

Example – Visible races for specific meetings
```bash
curl -s -X POST http://localhost:8000/v1/list-races \
-H "Content-Type: application/json" \
-d '{"filter":{"meeting_ids":[10,12],"visible_only":true}}'
```

If nothing matches, you get an empty array: `{ "races": [] }`.

---
### Step 2: Order Races by Advertised Start Time
Results are now always ordered by `advertised_start_time` ascending (earliest first) by default. You can reverse the order with `sort_direction`.

Field: `filter.sort_direction` (enum, optional)

Values:
* `SORT_DIRECTION_UNSPECIFIED` (or omitted) → ascending (earliest to latest)
* `SORT_DIRECTION_ASC` → ascending
* `SORT_DIRECTION_DESC` → descending (latest to earliest)

Example – Default ordering (ascending)
```bash
curl -s -X POST http://localhost:8000/v1/list-races \
-H "Content-Type: application/json" \
-d '{}'
```
Explanation: No `sort_direction` provided → ascending order.

Example – Explicit descending order
```bash
curl -s -X POST http://localhost:8000/v1/list-races \
-H "Content-Type: application/json" \
-d '{"filter":{"sort_direction":"SORT_DIRECTION_DESC"}}'
```
Explanation: Returns the most recently scheduled (or already started) races first.

Combine ordering with visibility:
```bash
curl -s -X POST http://localhost:8000/v1/list-races \
-H "Content-Type: application/json" \
-d '{"filter":{"visible_only":true, "sort_direction":"SORT_DIRECTION_ASC"}}'
```

Smoke Test Checklist for Ordering:
1. Call ascending (default) – confirm earliest advertised_start_time first.
2. Call descending – confirm order reversed.
3. Add `visible_only:true` – ordering still holds within filtered subset.

---
Upcoming Steps:
3. Add derived `status` (OPEN/CLOSED).
4. Add `GetRace` RPC for a single race.
5. Add separate sports service with `ListEvents`.

Feel free to copy/paste any curl above to exercise the API.
233 changes: 189 additions & 44 deletions api/proto/racing/racing.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading