fixed error, but enum values are still serialized as int
This commit is contained in:
parent
01dda53425
commit
dd4ae7def8
6
.vscode/launch.json
vendored
6
.vscode/launch.json
vendored
@ -15,9 +15,9 @@
|
|||||||
"SECRET_KEY" : "zdiTz8P3jXOc7jztIQAoelK4zztyuCpJ" // https://randomkeygen.com/
|
"SECRET_KEY" : "zdiTz8P3jXOc7jztIQAoelK4zztyuCpJ" // https://randomkeygen.com/
|
||||||
},
|
},
|
||||||
"args": [
|
"args": [
|
||||||
"run" //,
|
"run",
|
||||||
// "--no-debugger",
|
// "--no-debugger",
|
||||||
//"--no-reload"
|
"--no-reload"
|
||||||
],
|
],
|
||||||
"jinja": true,
|
"jinja": true,
|
||||||
"justMyCode": true
|
"justMyCode": true
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import pydapper
|
import pydapper
|
||||||
|
import pdb
|
||||||
|
|
||||||
from ..schemas import model
|
from ..schemas import model
|
||||||
from ..schemas.model import History
|
from ..schemas.model import History
|
||||||
@ -17,8 +18,6 @@ def GetHistory(options):
|
|||||||
try:
|
try:
|
||||||
pooledConnection = local_db.getPoolConnection()
|
pooledConnection = local_db.getPoolConnection()
|
||||||
commands = pydapper.using(pooledConnection)
|
commands = pydapper.using(pooledConnection)
|
||||||
h = History(1, 1, 1, "2020-01-01", "2020-01-01", model.ObjectType.shipcall, model.Operation.insert)
|
|
||||||
|
|
||||||
|
|
||||||
if "shipcall_id" in options and options["shipcall_id"]:
|
if "shipcall_id" in options and options["shipcall_id"]:
|
||||||
data = commands.query("SELECT id, participant_id, shipcall_id, timestamp, eta, type, operation FROM history WHERE shipcall_id = ?shipcallid?",
|
data = commands.query("SELECT id, participant_id, shipcall_id, timestamp, eta, type, operation FROM history WHERE shipcall_id = ?shipcallid?",
|
||||||
@ -29,6 +28,7 @@ def GetHistory(options):
|
|||||||
pooledConnection.close()
|
pooledConnection.close()
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
|
pdb.pm()
|
||||||
logging.error(ex)
|
logging.error(ex)
|
||||||
print(ex)
|
print(ex)
|
||||||
result = {}
|
result = {}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
from dataclasses import field, dataclass
|
from dataclasses import field, dataclass
|
||||||
from marshmallow import Schema, fields, INCLUDE, ValidationError
|
from marshmallow import Schema, fields, INCLUDE, ValidationError
|
||||||
from marshmallow_enum import EnumField
|
from marshmallow_enum import EnumField
|
||||||
from enum import Enum
|
from enum import IntEnum
|
||||||
|
|
||||||
from marshmallow_dataclass import dataclass
|
from marshmallow_dataclass import dataclass
|
||||||
from typing import List
|
from typing import List
|
||||||
@ -25,14 +25,16 @@ class Berth(Schema):
|
|||||||
modified: datetime
|
modified: datetime
|
||||||
deleted: bool
|
deleted: bool
|
||||||
|
|
||||||
class Operation(Enum):
|
class Operation(IntEnum):
|
||||||
insert = 1,
|
UNDEFINED = 0
|
||||||
update = 2,
|
INSERT = 1
|
||||||
delete = 3
|
UPDATE = 2
|
||||||
|
DELETE = 3
|
||||||
|
|
||||||
class ObjectType(Enum):
|
class ObjectType(IntEnum):
|
||||||
shipcall = 1,
|
UNDEFINED = 0
|
||||||
times = 2
|
SHIPCALL = 1
|
||||||
|
TIMES = 2
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class History:
|
class History:
|
||||||
@ -54,8 +56,8 @@ class History:
|
|||||||
type: EnumField(ObjectType)
|
type: EnumField(ObjectType)
|
||||||
operation: EnumField(Operation)
|
operation: EnumField(Operation)
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_query_row(self, id, participant_id, ship_id, timestamp, eta, type, operation):
|
def from_query_row(self, id, participant_id, shipcall_id, timestamp, eta, type, operation):
|
||||||
return self(id, participant_id, ship_id, timestamp, eta, ObjectType(type), Operation(operation))
|
return self(id, participant_id, shipcall_id, timestamp, eta, ObjectType(type), Operation(operation))
|
||||||
|
|
||||||
class Error(Schema):
|
class Error(Schema):
|
||||||
message = fields.String(required=True)
|
message = fields.String(required=True)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user