<commit_before># Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
# Author - <NAME> <<EMAIL>>

from __future__ import unicode_literals
import frappe
import json
from frappe import _, DoesNotExistError
from frappe.boot import get_allowed_pages, get_allowed_reports
from frappe.cache_manager import build_domain_restriced_doctype_cache, build_domain_restriced_page_cache, build_table_count_cache

class Workspace:
	def __init__(self, page_name):
		self.page_name = page_name

	def build_cache(self):
		self.doc = frappe.get_doc("Desk Page", self.page_name)
		self.get_pages_to_extend()

		user = frappe.get_user()
		user.build_permissions()
		self.user = user

		self.allowed_pages = get_allowed_pages()
		self.allowed_reports = get_allowed_reports()

		self.table_counts = build_table_count_cache()
		self.restricted_doctypes = build_domain_restriced_doctype_cache()
		self.restricted_pages = build_domain_restriced_page_cache()

	def get_pages_to_extend(self):
		pages = frappe.get_all("Desk Page", filters={
			"extends": self.page_name,
			'restrict_to_domain': ['in', frappe.get_active_domains()]<commit_msg>fix: use cache instead of building count<commit_after># Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
# Author - <NAME> <<EMAIL>>

from __future__ import unicode_literals
import frappe
import json
from frappe import _, DoesNotExistError
from frappe.boot import get_allowed_pages, get_allowed_reports
from frappe.cache_manager import build_domain_restriced_doctype_cache, build_domain_restriced_page_cache, build_table_count_cache

class Workspace:
	def __init__(self, page_name):
		self.page_name = page_name

	def build_cache(self):
		self.doc = frappe.get_doc("Desk Page", self.page_name)
		self.get_pages_to_extend()

		user = frappe.get_user()
		user.build_permissions()
		self.user = user

		self.allowed_pages = get_allowed_pages()
		self.allowed_reports = get_allowed_reports()

		self.table_counts = get_table_with_counts()
		self.restricted_doctypes = build_domain_restriced_doctype_cache()
		self.restricted_pages = build_domain_restriced_page_cache()

	def get_pages_to_extend(self):
		pages = frappe.get_all("Desk Page", filters={
			"extends": self.page_name,
			'restrict_to_domain': ['in', frappe.get_active_domains()]
{'fraction_non_alphanumeric': 0.08912579957356077, 'fraction_numerical': 0.003411513859275053, 'mean_word_length': 6.35423197492163, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 9, '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': '5660071', 'n_tokens_mistral': 857, 'n_tokens_neox': 799, 'n_words': 165}