-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
script to remove duplicated layout displays
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |