sfu-dhil / wphp

Women's Print History Project database front end.
https://womensprinthistoryproject.com/
GNU General Public License v2.0
1 stars 8 forks source link

Delete unverified persons with no titles attached #363

Closed kkatemoffatt closed 10 months ago

kkatemoffatt commented 11 months ago

What isn’t working as expected on the website?

We would like to delete all person records that are 1) unverified AND 2) have no titles attached to them.

If you encountered an error message, please copy the relevant details or take a screenshot and paste it below.

N/A

What is the URL of the page where you encountered the bug?

N/A

What steps did you take before you encountered the bug?

N/A

What browser, operating system, and device were you using when you encountered the error?

N/A

Additional information

Here's an example of a person record that is unverified and has no titles attached, and should be deleted: https://womensprinthistoryproject.com/person/5612

andrew-gardener commented 11 months ago

Hi Kate,

I've removed 523 person records

There were 2 edge cases that I didn't remove since they had firm relationship. You can decide if they need to be keep or removed as desired.

https://womensprinthistoryproject.com/person/10962 https://womensprinthistoryproject.com/person/10964

andrew-gardener commented 11 months ago

Historical bookkeeping (you can ignore)

/* find records */
SELECT person.*
FROM person
LEFT JOIN title_role ON person.id = title_role.person_id
WHERE person.finalcheck IS FALSE
AND title_role.id IS NULL;

/* find edge cases records */
SELECT person.*
FROM person
LEFT JOIN title_role ON person.id = title_role.person_id
JOIN person_firm ON person.id = person_firm.person_id
WHERE person.finalcheck IS FALSE
AND title_role.id IS NULL;

/* remove records (minus edge cases) */
DELETE person
FROM person
LEFT JOIN title_role ON person.id = title_role.person_id
WHERE person.finalcheck IS FALSE
AND title_role.id IS NULL
AND person.id NOT IN (10962, 10964);