Sort /packets descending by created.

This commit is contained in:
W1CDN 2023-04-16 16:59:09 -05:00
parent 19b3a54d98
commit 5793e57aa9

View File

@ -5,7 +5,7 @@ import configparser
import csv
import ast
import glob
import json
import json, operator
import sqlite3
api_app = Flask(__name__)
api = Api(api_app)
@ -51,7 +51,6 @@ def dict_factory(cursor, row):
def get_db_connection():
conn = sqlite3.connect('database.db')
#conn.row_factory = sqlite3.Row
conn.row_factory = dict_factory
return conn
@ -71,6 +70,9 @@ class Packets(Resource):
#data = read_logs(log_folder)
conn = get_db_connection()
data = select_all_frames(conn)
# Sort by created date, descending (https://stackoverflow.com/a/45266808)
data.sort(key=operator.itemgetter('created'), reverse=True)
#data.sort(key=created, reverse=True)
return {'data': data}, 200 # return data and 200 OK code
# Read config