Skip to content

Commit

Permalink
feat: API endpoint for determining if a roster is active.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shigbeard authored Nov 3, 2024
1 parent 8815592 commit 93501e7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/controllers/api/v1/rosters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ def show

render json: @roster, serializer: V1::Leagues::RosterSerializer
end

def active
@roster = League::Roster.includes(division: :league).find(params[:id])

league_status = @roster.division.league&.status
is_active = league_status.present? && league_status == 'running'

render json: {
id: @roster.id,
active: is_active
}
end
end
end
end
13 changes: 13 additions & 0 deletions docs/api/v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,19 @@ Example:
}
```

### GET `/rosters/active/:id`

Options:
- `:id`, the unique id of the roster

Example:
```json
{
"roster": 1,
"active": true
}
```

## Matches

### Resource
Expand Down

0 comments on commit 93501e7

Please sign in to comment.