HeatSerializer: Based on Heat Model, displays lane_num, athlete, athlete_full_name, seed_time, heat_time
LaneSerializer: Based on Heat Model, displays num_heat , athlete, athlete_full_name, heat_time.
It contains an update function that updates the heat_time of an instance and registers this time on TimeRecord.
backend/api/views/HeatView.py
Contains two classes:
HeatView: Uses HeatSerializer and, given an event and heat number, displays all the lanes of the set heat.
LaneView: Uses LaneSerializer and, given an event and lane number, displays all heats on set lane. It contains an update function to register all the times recorded on that lane during the event.
Use event_id = 1 to retrieve all the athletes and their seed times. Copy the response.
POST api/event_heat/{event_id}/
Use event_id = 1 and add the previously copied response to athletes in the request body. Delete the athlete_full_name for each entry. Execute. This action generates all the heats for the event.
This PR address issue #58
It depends on PR #75
Implementation
Created two serializer:
HeatSerializer
: Based on Heat Model, displayslane_num
,athlete
,athlete_full_name
,seed_time
,heat_time
LaneSerializer
: Based on Heat Model, displaysnum_heat
,athlete
,athlete_full_name
,heat_time
. It contains an update function that updates theheat_time
of an instance and registers this time onTimeRecord
.Contains two classes:
HeatView
: UsesHeatSerializer
and, given anevent
andheat number
, displays all the lanes of the set heat.LaneView
: UsesLaneSerializer
and, given anevent
andlane number
, displays all heats on set lane. It contains anupdate
function to register all the times recorded on that lane during the event.Added two endpoints:
event_heat/<int:event_id>/<int:heat_num>/
: UsesHeatView
.event_lane/<int:event_id>/<int:lane_num>/
: UsesLaneView
.Swagger
Steps to tests:
Use
event_id = 1
to retrieve all the athletes and their seed times. Copy the response.Use
event_id = 1
and add the previously copied response to athletes in the request body. Delete theathlete_full_name
for each entry. Execute. This action generates all the heats for the event.Result event_id = 1 and heat_num = 1
[ { "id": 1, "lane_num": 1, "athlete": 11, "athlete_full_name": "Sofia Avila", "seed_time": "NT", "heat_time": null }, { "id": 3, "lane_num": 2, "athlete": 12, "athlete_full_name": "Ellie Yuan", "seed_time": "00:00:41.840000", "heat_time": null }, { "id": 4, "lane_num": 3, "athlete": 8, "athlete_full_name": "Kyla Smith", "seed_time": "00:00:41.540000", "heat_time": null }, { "id": 2, "lane_num": 4, "athlete": 2, "athlete_full_name": "Ana Gomez", "seed_time": "00:00:45.100000", "heat_time": null }, { "id": null, "lane_num": 5, "athlete": null, "athlete_full_name": null, "seed_time": "", "heat_time": null } ]Result event_id = 1 and heat_num = 2
[ { "id": 6, "lane_num": 1, "athlete": 10, "athlete_full_name": "Anna Anderson", "seed_time": "00:00:38.540000", "heat_time": null }, { "id": 8, "lane_num": 2, "athlete": 16, "athlete_full_name": "Ava Wilson", "seed_time": "00:00:37.810000", "heat_time": null }, { "id": 9, "lane_num": 3, "athlete": 6, "athlete_full_name": "Laura Sanchez", "seed_time": "00:00:31.360000", "heat_time": null }, { "id": 7, "lane_num": 4, "athlete": 15, "athlete_full_name": "Olivia Davis", "seed_time": "00:00:38.540000", "heat_time": null }, { "id": 5, "lane_num": 5, "athlete": 4, "athlete_full_name": "Elena Lopez", "seed_time": "00:00:39.210000", "heat_time": null } ]Result event_id = 1 and heat_num = 3
{ "error": "There is not a heat with that number" }Result event_id = 1 and lane_num = 1
[ { "id": 1, "num_heat": 1, "athlete": 11, "athlete_full_name": "Sofia Avila" }, { "id": 6, "num_heat": 2, "athlete": 10, "athlete_full_name": "Anna Anderson" } ]Result event_id = 1 and lane_num = 2
[ { "id": 3, "num_heat": 1, "athlete": 12, "athlete_full_name": "Ellie Yuan" }, { "id": 8, "num_heat": 2, "athlete": 16, "athlete_full_name": "Ava Wilson" } ]Result event_id = 1 and lane_num = 3
[ { "id": 4, "num_heat": 1, "athlete": 8, "athlete_full_name": "Kyla Smith" }, { "id": 9, "num_heat": 2, "athlete": 6, "athlete_full_name": "Laura Sanchez" } ]Result event_id = 1 and lane_num = 4
[ { "id": 2, "num_heat": 1, "athlete": 2, "athlete_full_name": "Ana Gomez" }, { "id": 7, "num_heat": 2, "athlete": 15, "athlete_full_name": "Olivia Davis" } ]Result event_id = 1 and lane_num = 5
[ { "id": null, "num_heat": 1, "athlete": null, "athlete_full_name": null }, { "id": 5, "num_heat": 2, "athlete": 4, "athlete_full_name": "Elena Lopez" } ]Result event_id = 1 and lane_num = 6
{ "error": "There is not a lane with that number" }Data used:
Request body using event_id = 1 and lane_num = 1
[ { "num_heat": 1, "athlete": 11, "heat_time":"39.01" }, { "num_heat": 2, "athlete": 10, "heat_time":"NS" } ]Request body using event_id = 1 and lane_num = 2
[ { "num_heat": 1, "athlete": 12, "heat_time":"DQ" }, { "num_heat": 2, "athlete": 16, "heat_time":"40.78" } ]Request body using event_id = 1 and lane_num = 3
[ { "num_heat": 1, "athlete": 8, "heat_time":"32.12" }, { "num_heat": 2, "athlete": 6, "heat_time":"36.29" } ]Request body using event_id = 1 and lane_num = 4
[ { "num_heat": 1, "athlete": 2, "heat_time":"31.45" }, { "num_heat": 2, "athlete": 15, "heat_time":"27.92" } ]Request body using event_id = 1 and lane_num = 5
[ { "num_heat": 1, "athlete": null, "heat_time":"" }, { "num_heat": 2, "athlete": 4, "heat_time":"25.43" } ]Heat
on the databaseTimeRecord
on the database:Now the heat times are not null:
Event 1 Heat 1
[ { "id": 1, "lane_num": 1, "athlete": 11, "athlete_full_name": "Sofia Avila", "seed_time": "NT", "heat_time": "00:00:39.010000" }, { "id": 3, "lane_num": 2, "athlete": 12, "athlete_full_name": "Ellie Yuan", "seed_time": "00:00:41.840000", "heat_time": "DQ" }, { "id": 4, "lane_num": 3, "athlete": 8, "athlete_full_name": "Kyla Smith", "seed_time": "00:00:41.540000", "heat_time": "00:00:32.120000" }, { "id": 2, "lane_num": 4, "athlete": 2, "athlete_full_name": "Ana Gomez", "seed_time": "00:00:45.100000", "heat_time": "00:00:31.450000" }, { "id": null, "lane_num": 5, "athlete": null, "athlete_full_name": null, "seed_time": null, "heat_time": null } ]Event 1 Heat 2
[ { "id": 6, "lane_num": 1, "athlete": 10, "athlete_full_name": "Anna Anderson", "seed_time": "00:00:38.540000", "heat_time": "NS" }, { "id": 8, "lane_num": 2, "athlete": 16, "athlete_full_name": "Ava Wilson", "seed_time": "00:00:37.810000", "heat_time": "00:00:40.780000" }, { "id": 9, "lane_num": 3, "athlete": 6, "athlete_full_name": "Laura Sanchez", "seed_time": "00:00:31.360000", "heat_time": "00:00:36.290000" }, { "id": 7, "lane_num": 4, "athlete": 15, "athlete_full_name": "Olivia Davis", "seed_time": "00:00:38.540000", "heat_time": "00:00:27.920000" }, { "id": 5, "lane_num": 5, "athlete": 4, "athlete_full_name": "Elena Lopez", "seed_time": "00:00:39.210000", "heat_time": "00:00:25.430000" } ]