Missing title field in database events column #4

Merged
dylan merged 4 commits from fix/missing-title-field-database into main 2026-03-02 19:00:14 +00:00
3 changed files with 10 additions and 3 deletions
Showing only changes of commit c9151da643 - Show all commits

View File

@@ -3,6 +3,7 @@ import psycopg2
import pandas as pd import pandas as pd
from psycopg2.extras import RealDictCursor from psycopg2.extras import RealDictCursor
from psycopg2.extras import execute_batch, Json from psycopg2.extras import execute_batch, Json
from server.exceptions import NotExistentDatasetException
class PostgresConnector: class PostgresConnector:
@@ -133,7 +134,7 @@ class PostgresConnector:
if result: if result:
return pd.DataFrame(result) return pd.DataFrame(result)
raise ValueError("Dataset does not exist") raise NotExistentDatasetException("Dataset does not exist")
def get_dataset_info(self, dataset_id: int) -> dict: def get_dataset_info(self, dataset_id: int) -> dict:
query = "SELECT * FROM datasets WHERE id = %s" query = "SELECT * FROM datasets WHERE id = %s"
@@ -141,7 +142,7 @@ class PostgresConnector:
if result: if result:
return result[0] return result[0]
raise ValueError("Dataset does not exist") raise NotExistentDatasetException("Dataset does not exist")
def close(self): def close(self):
if self.connection: if self.connection:

View File

@@ -13,7 +13,7 @@ from flask_jwt_extended import (
from server.stat_gen import StatGen from server.stat_gen import StatGen
from server.dataset_processor import DatasetProcessor from server.dataset_processor import DatasetProcessor
from server.exceptions import NotAuthorisedException from server.exceptions import NotAuthorisedException, NotExistentDatasetException
from db.database import PostgresConnector from db.database import PostgresConnector
from server.auth import AuthManager from server.auth import AuthManager
from server.utils import get_request_filters, get_dataset_and_validate from server.utils import get_request_filters, get_dataset_and_validate
@@ -160,7 +160,10 @@ def get_dataset(dataset_id):
return jsonify(filtered_dataset), 200 return jsonify(filtered_dataset), 200
except NotAuthorisedException: except NotAuthorisedException:
return jsonify({"error": "User is not authorised to access this content"}), 403 return jsonify({"error": "User is not authorised to access this content"}), 403
except NotExistentDatasetException:
return jsonify({"error": "Dataset does not exist"}), 404
except Exception: except Exception:
print(traceback.format_exc())
return jsonify({"error": "An unexpected error occured"}), 500 return jsonify({"error": "An unexpected error occured"}), 500

View File

@@ -1,2 +1,5 @@
class NotAuthorisedException(Exception): class NotAuthorisedException(Exception):
pass pass
class NotExistentDatasetException(Exception):
pass