<commit_before># Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt

from __future__ import unicode_literals
import webnotes

def execute():
	webnotes.reload_doc("setup", "doctype", "email_digest")
	
	from webnotes.profile import get_system_managers
	system_managers = get_system_managers(only_name=True)
	if not system_managers: 
		return
	
	# no default company
	company = webnotes.conn.get_default("company")
	if not company:
		company = webnotes.conn.sql_list("select name from `tabCompany`")
		if company:
			company = company[0]
	if not company:
		return
	
	# scheduler errors digest
	edigest = webnotes.new_bean("Email Digest")
	edigest.doc.fields.update({
		"name": "Scheduler Errors",
		"company": company,
		"frequency": "Daily",
		"enabled": 1,
		"recipient_list": "\n".join(system_managers),
		"scheduler_errors": 1
	})
	edigest.insert()<commit_msg>fix company email digest patch<commit_after># Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt

from __future__ import unicode_literals
import webnotes

def execute():
	webnotes.reload_doc("setup", "doctype", "email_digest")
	
	from webnotes.profile import get_system_managers
	system_managers = get_system_managers(only_name=True)
	if not system_managers: 
		return
	
	# no default company
	company = webnotes.conn.sql_list("select name from `tabCompany`")
	if company:
		company = company[0]
	if not company:
		return
	
	# scheduler errors digest
	edigest = webnotes.new_bean("Email Digest")
	edigest.doc.fields.update({
		"name": "Scheduler Errors",
		"company": company,
		"frequency": "Daily",
		"enabled": 1,
		"recipient_list": "\n".join(system_managers),
		"scheduler_errors": 1
	})
	edigest.insert()
{'fraction_non_alphanumeric': 0.11178082191780822, 'fraction_numerical': 0.008767123287671232, 'mean_word_length': 5.168918918918919, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3509803', 'n_tokens_mistral': 651, 'n_tokens_neox': 591, 'n_words': 162}