diff --git a/misc/BreCalApi.yaml b/misc/BreCalApi.yaml index 82a42e3..4836513 100644 --- a/misc/BreCalApi.yaml +++ b/misc/BreCalApi.yaml @@ -331,7 +331,7 @@ components: type: integer shipcallId: description: The unique identifier of a ship call - type: integer + type: integer shipcall: type: object required: @@ -421,8 +421,13 @@ components: participants: type: array items: - type: integer - example: [1, 5, 7] + type: object + properties: + participant_id: + type: integer + type: + type: integer + example: [{ "participant_id" : 1, "type" : 1}, { "participant_id" : 5, "type": 2}, { "participant_id" : 7, "type" : 3} ] created: type: string format: date-time diff --git a/misc/create_schema.sql b/misc/create_schema.sql index 5bdb3e8..adbe508 100644 --- a/misc/create_schema.sql +++ b/misc/create_schema.sql @@ -225,6 +225,7 @@ CREATE TABLE `shipcall_participant_map` ( `id` int NOT NULL AUTO_INCREMENT, `shipcall_id` int unsigned DEFAULT NULL, `participant_id` int unsigned DEFAULT NULL, + `type` int unsigned DEFAULT NULL COMMENT 'Type of participant role', `created` datetime DEFAULT CURRENT_TIMESTAMP, `modified` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), diff --git a/src/server/BreCal/impl/shipcalls.py b/src/server/BreCal/impl/shipcalls.py index fdf0b78..2bf0bae 100644 --- a/src/server/BreCal/impl/shipcalls.py +++ b/src/server/BreCal/impl/shipcalls.py @@ -22,8 +22,9 @@ def GetShipcalls(options): "anchored, moored_lock, canceled, evaluation, evaluation_message, created, modified FROM shipcall WHERE eta IS NULL OR eta >= DATE(NOW() - INTERVAL 2 DAY) " + "ORDER BY eta", model=model.Shipcall) for shipcall in data: - participant_query = "SELECT participant_id FROM shipcall_participant_map WHERE shipcall_id=?shipcall_id?"; + participant_query = "SELECT participant_id, type FROM shipcall_participant_map WHERE shipcall_id=?shipcall_id?"; for record in commands.query(participant_query, model=dict, param={"shipcall_id" : shipcall.id}, buffered=False): + # model.Participant_Assignment = model.Participant_Assignment() shipcall.participants.append(record["participant_id"]) pooledConnection.close() diff --git a/src/server/BreCal/schemas/model.py b/src/server/BreCal/schemas/model.py index 7b056c9..0d70a87 100644 --- a/src/server/BreCal/schemas/model.py +++ b/src/server/BreCal/schemas/model.py @@ -93,6 +93,11 @@ class ShipcallSchema(Schema): created = fields.DateTime(Required = False, allow_none=True) modified = fields.DateTime(Required = False, allow_none=True) +@dataclass +class Participant_Assignment: + participant_id: int + type: int + @dataclass class Shipcall: @@ -123,7 +128,7 @@ class Shipcall: evaluation_message: str created: datetime modified: datetime - participants: List[int] = field(default_factory=list) + participants: List[Participant_Assignment] = field(default_factory=list) class ShipcallId(Schema): pass