Esempio n. 1
0
def get_event_logs():
    conn = engine.connect()
    event_logs = conn.execute(select([eventlog]))
    event_logs = rows_to_dict(event_logs.keys(), event_logs.fetchall())
    if len(event_logs) == 0:
        abort(404)
    return jsonify(event_logs=event_logs), 200
Esempio n. 2
0
def get_events():
    params = request.args.to_dict()
    conn = engine.connect()
    query = build_select()

    if 'event_id' in params:
        query = query.where(event.c.id == params['event_id'])
    if 'startDate' in params:
        query = query.where(event.c.date >= datetime.strptime(params['startDate'], '%Y-%m-%d'))
    if 'endDate' in params:
        query = query.where(event.c.date <= datetime.strptime(params['endDate'], '%Y-%m-%d'))
    if 'createdDateStart' in params:
        query = query.where(event.c.created >= datetime.strptime(params['createdDateStart'], '%Y-%m-%d'))
    if 'createdDateEnd' in params:
        query = query.where(event.c.created <= datetime.strptime(params['createdDateEnd'], '%Y-%m-%d'))
    if 'city' in params:
        query = query.where(event.c.city == params['city'])

    events = conn.execute(query)
    events = rows_to_dict(events.keys(), events.fetchall())
    if len(events) == 0:
        abort(404)
    events = pretty_events(events)
    return jsonify(events=events), 200
Esempio n. 3
0
 def __init__(self, server, token, source=None, log_config_path='logging.json'):
     self.token = token
     self.server = server
     self.connection = engine.connect()
     self.source = source
     self.logger = self.setup_logging(log_config_path)