36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
import json
|
|
import logging
|
|
import pydapper
|
|
|
|
from ..schemas import model
|
|
from .. import local_db
|
|
from BreCal.database.sql_queries import SQLQuery
|
|
|
|
def GetNotifications(options):
|
|
"""
|
|
:param options: A dictionary containing all the paramters for the Operations
|
|
options["shipcall_id"]: **Id**. *Example: 42*. Id of referenced ship call.
|
|
|
|
"""
|
|
|
|
try:
|
|
|
|
pooledConnection = local_db.getPoolConnection()
|
|
commands = pydapper.using(pooledConnection)
|
|
# query = SQLQuery.get_notifications()
|
|
# data = commands.query(query, model=model.Notification.from_query_row, param={"scid" : options["shipcall_id"]})
|
|
data = commands.query("SELECT id, shipcall_id, participant_id, level, type, message, created, modified FROM notification " +
|
|
"WHERE shipcall_id = ?scid?", model=model.Notification.from_query_row, param={"scid" : options["shipcall_id"]})
|
|
pooledConnection.close()
|
|
|
|
except Exception as ex:
|
|
logging.error(ex)
|
|
print(ex)
|
|
result = {}
|
|
result["error_field"] = "call failed"
|
|
return json.dumps(result), 500, {'Content-Type': 'application/json; charset=utf-8'}
|
|
|
|
return json.dumps(data, default=model.obj_dict), 200, {'Content-Type': 'application/json; charset=utf-8'}
|
|
|
|
|