43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
import json
|
|
import logging
|
|
import pydapper
|
|
import pdb
|
|
|
|
from ..schemas import model
|
|
from ..schemas.model import History
|
|
|
|
from .. import local_db
|
|
from BreCal.database.sql_queries import SQLQuery
|
|
|
|
def GetHistory(options):
|
|
|
|
"""
|
|
:param options: A dictionary containing all the paramters for the Operations
|
|
options["shipcall_id"]: **Id of shipcall**.
|
|
"""
|
|
|
|
try:
|
|
pooledConnection = local_db.getPoolConnection()
|
|
commands = pydapper.using(pooledConnection)
|
|
|
|
if "shipcall_id" in options and options["shipcall_id"]:
|
|
# query = SQLQuery.get_history()
|
|
# data = commands.query(query, model=History.from_query_row, param={"shipcallid" : options["shipcall_id"]})
|
|
data = commands.query("SELECT id, participant_id, shipcall_id, timestamp, eta, type, operation FROM history WHERE shipcall_id = ?shipcallid?",
|
|
model=History.from_query_row,
|
|
param={"shipcallid" : options["shipcall_id"]})
|
|
|
|
|
|
pooledConnection.close()
|
|
|
|
except Exception as ex:
|
|
pdb.pm()
|
|
logging.error(ex)
|
|
print(ex)
|
|
result = {}
|
|
result["error_field"] = "call failed"
|
|
return json.dumps("call failed"), 500
|
|
|
|
return json.dumps(data, default=model.obj_dict), 200, {'Content-Type': 'application/json; charset=utf-8'}
|
|
|