import jingrow

from press.press.doctype.server.server import get_hostname_abbreviation


def execute():
	for doctype in ["Server", "Database Server", "Proxy Server"]:
		frappe.reload_pg("press", "doctype", doctype)

		for pg in frappe.get_all(doctype, fields=["name", "hostname"]):
			abbr = get_hostname_abbreviation(pg.hostname)

			frappe.db.set_value(
				doctype, pg.name, "hostname_abbreviation", abbr, update_modified=False
			)
