added type flag to participant assignment for ship call pt. 1

This commit is contained in:
Daniel Schick 2023-10-07 13:41:32 +02:00
parent c282f5d5e0
commit dc30fe9c53
4 changed files with 17 additions and 5 deletions

View File

@ -331,7 +331,7 @@ components:
type: integer type: integer
shipcallId: shipcallId:
description: The unique identifier of a ship call description: The unique identifier of a ship call
type: integer type: integer
shipcall: shipcall:
type: object type: object
required: required:
@ -421,8 +421,13 @@ components:
participants: participants:
type: array type: array
items: items:
type: integer type: object
example: [1, 5, 7] 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: created:
type: string type: string
format: date-time format: date-time

View File

@ -225,6 +225,7 @@ CREATE TABLE `shipcall_participant_map` (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,
`shipcall_id` int unsigned DEFAULT NULL, `shipcall_id` int unsigned DEFAULT NULL,
`participant_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, `created` datetime DEFAULT CURRENT_TIMESTAMP,
`modified` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, `modified` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),

View File

@ -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) " + "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) "ORDER BY eta", model=model.Shipcall)
for shipcall in data: 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): 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"]) shipcall.participants.append(record["participant_id"])
pooledConnection.close() pooledConnection.close()

View File

@ -93,6 +93,11 @@ class ShipcallSchema(Schema):
created = fields.DateTime(Required = False, allow_none=True) created = fields.DateTime(Required = False, allow_none=True)
modified = 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 @dataclass
class Shipcall: class Shipcall:
@ -123,7 +128,7 @@ class Shipcall:
evaluation_message: str evaluation_message: str
created: datetime created: datetime
modified: datetime modified: datetime
participants: List[int] = field(default_factory=list) participants: List[Participant_Assignment] = field(default_factory=list)
class ShipcallId(Schema): class ShipcallId(Schema):
pass pass