forked from FrederikBaerentsen/BrickTracker
Built-in fix for 'None' entries in the missing table
This commit is contained in:
parent
e4d052f22c
commit
0d9276f639
@ -58,4 +58,9 @@ CREATE TABLE IF NOT EXISTS missing (
|
|||||||
u_id TEXT
|
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;
|
COMMIT;
|
3
bricktracker/sql/missing/count_none.sql
Normal file
3
bricktracker/sql/missing/count_none.sql
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
SELECT count(*) AS count
|
||||||
|
FROM missing
|
||||||
|
WHERE element_id = 'None'
|
@ -36,6 +36,7 @@ def admin() -> str:
|
|||||||
counters: dict[str, int] = {}
|
counters: dict[str, int] = {}
|
||||||
exception: Exception | None = None
|
exception: Exception | None = None
|
||||||
is_init: bool = False
|
is_init: bool = False
|
||||||
|
count_none: int = 0
|
||||||
|
|
||||||
# This view needs to be protected against SQL errors
|
# This view needs to be protected against SQL errors
|
||||||
try:
|
try:
|
||||||
@ -43,6 +44,11 @@ def admin() -> str:
|
|||||||
|
|
||||||
if is_init:
|
if is_init:
|
||||||
counters = BrickSQL.count_records()
|
counters = BrickSQL.count_records()
|
||||||
|
|
||||||
|
record = BrickSQL().fetchone('missing/count_none')
|
||||||
|
if record is not None:
|
||||||
|
count_none = record['count']
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
exception = e
|
exception = e
|
||||||
|
|
||||||
@ -67,6 +73,7 @@ def admin() -> str:
|
|||||||
'admin.html',
|
'admin.html',
|
||||||
configuration=BrickConfigurationList.list(),
|
configuration=BrickConfigurationList.list(),
|
||||||
counters=counters,
|
counters=counters,
|
||||||
|
count_none=count_none,
|
||||||
error=request.args.get('error'),
|
error=request.args.get('error'),
|
||||||
exception=exception,
|
exception=exception,
|
||||||
instructions=BrickInstructionsList(),
|
instructions=BrickInstructionsList(),
|
||||||
|
@ -13,6 +13,18 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
{% if count_none %}
|
||||||
|
<div class="alert alert-warning" role="alert">
|
||||||
|
<p>
|
||||||
|
Your <code>missing</code> table contains <code>"None"</code> entries (instead of <code>NULL</code>). <br>
|
||||||
|
This can lead to "phantom" missing parts appearing in your sets if you are coming from the original version of BrickTracker.
|
||||||
|
</p>
|
||||||
|
<hr>
|
||||||
|
<form action="{{ url_for('admin.init_database') }}" method="post" class="text-end">
|
||||||
|
<button type="submit" class="btn btn-warning"><i class="ri-capsule-line"></i> Apply the fix</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
<p><i class="ri-checkbox-circle-line"></i> The database is initialized.</p>
|
<p><i class="ri-checkbox-circle-line"></i> The database is initialized.</p>
|
||||||
<p>
|
<p>
|
||||||
<a href="{{ url_for('admin.download_database') }}" class="btn btn-primary" role="button"><i class="ri-download-line"></i> Download the database file</a>
|
<a href="{{ url_for('admin.download_database') }}" class="btn btn-primary" role="button"><i class="ri-download-line"></i> Download the database file</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user