Skip to content

Commit

Permalink
script to remove duplicated layout displays
Browse files Browse the repository at this point in the history
  • Loading branch information
adkinsrs committed Aug 13, 2024
1 parent 98ed357 commit a7c1f06
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions bin/remove_duplicate_layout_displays.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit a7c1f06

Please sign in to comment.