mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-05 05:09:11 +00:00
[fix] remove duplicate newsletter subscribers
This commit is contained in:
1
erpnext/patches/v6_2/__init__.py
Normal file
1
erpnext/patches/v6_2/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
12
erpnext/patches/v6_2/remove_newsletter_duplicates.py
Normal file
12
erpnext/patches/v6_2/remove_newsletter_duplicates.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
duplicates = frappe.db.sql("""select newsletter_list, email, count(name)
|
||||
from `tabNewsletter List Subscriber`
|
||||
group by newsletter_list, email
|
||||
having count(name) > 1""")
|
||||
|
||||
# delete all duplicates except 1
|
||||
for newsletter_list, email, count in duplicates:
|
||||
frappe.db.sql("""delete from `tabNewsletter List Subscriber`
|
||||
where newsletter_list=%s and email=%s limit %s""", (newsletter_list, email, count-1))
|
||||
Reference in New Issue
Block a user