From a7c1f06490f6db8415fe0236a71c59d0ae4eb5bd Mon Sep 17 00:00:00 2001 From: adkinsrs Date: Tue, 13 Aug 2024 13:21:14 -0400 Subject: [PATCH] script to remove duplicated layout displays --- bin/remove_duplicate_layout_displays.py | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 bin/remove_duplicate_layout_displays.py diff --git a/bin/remove_duplicate_layout_displays.py b/bin/remove_duplicate_layout_displays.py new file mode 100644 index 00000000..a72ad01c --- /dev/null +++ b/bin/remove_duplicate_layout_displays.py @@ -0,0 +1,30 @@ +#!/opt/bin/python + +# This is to fix an issue where some layouts have duplicated display members, if the user +# saved layouts in the layout arranger when the duplcation bug was active (https://github.com/IGS/gEAR/issues/768) + +import sys + +from pathlib import Path +lib_path = Path(__file__).resolve().parents[1].joinpath('lib') + +sys.path.append(str(lib_path)) + +import geardb + +conn = geardb.Connection() +cursor = conn.get_cursor() + +# https://www.tutorialspoint.com/mysql/mysql-delete-duplicate-records.htm +qry = """ +DELETE FROM layout_displays ld1 +INNER JOIN layout_displays ld2 +WHERE ld1.layout_id = ld2.layout_id +AND ld1.display_id = ld2.display_id +AND ld1.start_col = ld2.start_col +AND ld1.grid_width = ld2.grid_width +AND ld1.start_row = ld2.start_row +AND ld1.grid_height = ld2.grid_height +AND ld1.id > ld2.id +""" +cursor.execute(qry) \ No newline at end of file