diff --git a/bricktracker/sql/migrations/init.sql b/bricktracker/sql/migrations/init.sql index f243b8c..85defbb 100644 --- a/bricktracker/sql/migrations/init.sql +++ b/bricktracker/sql/migrations/init.sql @@ -58,4 +58,9 @@ CREATE TABLE IF NOT EXISTS missing ( u_id TEXT ); +-- Fix a bug where 'None' was inserted in missing instead of NULL +UPDATE missing +SET element_id = NULL +WHERE element_id = 'None'; + COMMIT; \ No newline at end of file diff --git a/bricktracker/sql/missing/count_none.sql b/bricktracker/sql/missing/count_none.sql new file mode 100644 index 0000000..3f4073b --- /dev/null +++ b/bricktracker/sql/missing/count_none.sql @@ -0,0 +1,3 @@ +SELECT count(*) AS count +FROM missing +WHERE element_id = 'None' diff --git a/bricktracker/views/admin.py b/bricktracker/views/admin.py index 6315d60..2a5addf 100644 --- a/bricktracker/views/admin.py +++ b/bricktracker/views/admin.py @@ -36,6 +36,7 @@ def admin() -> str: counters: dict[str, int] = {} exception: Exception | None = None is_init: bool = False + count_none: int = 0 # This view needs to be protected against SQL errors try: @@ -43,6 +44,11 @@ def admin() -> str: if is_init: counters = BrickSQL.count_records() + + record = BrickSQL().fetchone('missing/count_none') + if record is not None: + count_none = record['count'] + except Exception as e: exception = e @@ -67,6 +73,7 @@ def admin() -> str: 'admin.html', configuration=BrickConfigurationList.list(), counters=counters, + count_none=count_none, error=request.args.get('error'), exception=exception, instructions=BrickInstructionsList(), diff --git a/templates/admin/database.html b/templates/admin/database.html index 1710d7d..7b15397 100644 --- a/templates/admin/database.html +++ b/templates/admin/database.html @@ -13,6 +13,18 @@ {% else %} + {% if count_none %} +
+ Your missing
table contains "None"
entries (instead of NULL
).
+ This can lead to "phantom" missing parts appearing in your sets if you are coming from the original version of BrickTracker.
+
The database is initialized.