added type flag to participant assignment for ship call pt. 1
This commit is contained in:
parent
c282f5d5e0
commit
dc30fe9c53
@ -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
|
||||
|
||||
@ -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`),
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user