from jcloude.api.account import get_jingrow_io_auth_url

from . import __version__ as app_version

app_name = "jcloude"
app_title = "Jcloude"
app_publisher = "Jingrow"
app_description = "Managed Jingrow Hosting"
app_icon = "octicon octicon-rocket"
app_color = "grey"
app_email = "aditya@framework.jingrow.com"
app_license = "GNU Affero General Public License v3.0"
version = app_version

# Includes in <head>
# ------------------

# include js, css files in header of desk.html
# app_include_css = "/assets/jcloude/css/jcloude.css"
# app_include_js = "/assets/jcloude/js/jcloude.js"
app_include_js = [
	"jcloude.bundle.js",
]

# include js, css files in header of web template
# web_include_css = "/assets/jcloude/css/jcloude.css"
# web_include_js = "/assets/jcloude/js/jcloude.js"

# include js in page
# page_js = {"page" : "public/js/file.js"}

# include js in pagetype views
# pagetype_js = {"pagetype" : "public/js/pagetype.js"}
# pagetype_list_js = {"pagetype" : "public/js/pagetype_list.js"}
# pagetype_tree_js = {"pagetype" : "public/js/pagetype_tree.js"}
# pagetype_calendar_js = {"pagetype" : "public/js/pagetype_calendar.js"}

# Home Pages
# ----------

# application home page (will override Website Settings)
# home_page = "login"

# website user home page (by Role)
# role_home_page = {
# 	"Role": "home_page"
# }

# Website user home page (by function)
# get_website_user_home_page = "jcloude.utils.get_home_page"

# Generators
# ----------

# automatically create page for each record of this pagetype
# website_generators = ["Web Page"]

look_for_sidebar_json = True

base_template_map = {
	r"docs.*": "templates/pg.html",
	r"internal.*": "templates/pg.html",
}

update_website_context = ["jcloude.overrides.update_website_context"]

website_route_rules = [
	{"from_route": "/dashboard/<path:app_path>", "to_route": "dashboard"},
]

website_redirects = [
	{"source": "/dashboard/f-login", "target": get_jingrow_io_auth_url() or "/"},
	{
		"source": "/suspended-site",
		"target": "/api/method/jcloude.api.handle_suspended_site_redirection",
	},
	{"source": "/f-login", "target": "/dashboard/f-login"},
	{"source": "/signup", "target": "/erpnext/signup"},
]

email_css = ["/assets/jcloude/css/email.css"]

jinja = {
	"filters": ["jcloude.jcloude.pagetype.marketplace_app.utils.number_k_format"],
	"methods": ["jcloude.utils.get_country_info"],
}

# Installation
# ------------

# before_install = "jcloude.install.before_install"
after_install = "jcloude.install.after_install"
after_migrate = ["jcloude.api.account.clear_country_list_cache", "jcloude.sanity.checks"]

# Desk Notifications
# ------------------
# See jingrow.core.notifications.get_notification_config

notification_config = "jcloude.notifications.get_notification_config"

# Permissions
# -----------
# Permissions evaluated in scripted ways

permission_query_conditions = {
	"Site": "jcloude.jcloude.pagetype.site.site.get_permission_query_conditions",
	"Site Backup": "jcloude.jcloude.pagetype.site_backup.site_backup.get_permission_query_conditions",
	"Site Domain": ("jcloude.jcloude.pagetype.site_domain.site_domain.get_permission_query_conditions"),
	"TLS Certificate": "jcloude.jcloude.pagetype.tls_certificate.tls_certificate.get_permission_query_conditions",
	"Team": "jcloude.jcloude.pagetype.team.team.get_permission_query_conditions",
	"Subscription": ("jcloude.jcloude.pagetype.subscription.subscription.get_permission_query_conditions"),
	"Stripe Payment Method": "jcloude.jcloude.pagetype.stripe_payment_method.stripe_payment_method.get_permission_query_conditions",
	"Balance Transaction": "jcloude.jcloude.pagetype.balance_transaction.balance_transaction.get_permission_query_conditions",
	"Invoice": "jcloude.jcloude.pagetype.invoice.invoice.get_permission_query_conditions",
	"App Source": ("jcloude.jcloude.pagetype.app_source.app_source.get_permission_query_conditions"),
	"App Release": ("jcloude.jcloude.pagetype.app_release.app_release.get_permission_query_conditions"),
	"Release Group": "jcloude.jcloude.pagetype.release_group.release_group.get_permission_query_conditions",
	"Deploy Candidate": "jcloude.jcloude.pagetype.deploy_candidate.deploy_candidate.get_permission_query_conditions",
	"Deploy Candidate Difference": "jcloude.jcloude.pagetype.deploy_candidate_difference.deploy_candidate_difference.get_permission_query_conditions",
	"Deploy": "jcloude.jcloude.pagetype.deploy.deploy.get_permission_query_conditions",
	"Bench": "jcloude.jcloude.pagetype.bench.bench.get_permission_query_conditions",
	"Server": "jcloude.jcloude.pagetype.server.server.get_permission_query_conditions",
	"Database Server": "jcloude.jcloude.pagetype.database_server.database_server.get_permission_query_conditions",
	"Virtual Machine": "jcloude.jcloude.pagetype.virtual_machine.virtual_machine.get_permission_query_conditions",
	"Jcloude Webhook": "jcloude.jcloude.pagetype.jcloude_webhook.jcloude_webhook.get_permission_query_conditions",
	"Jcloude Webhook Log": "jcloude.jcloude.pagetype.jcloude_webhook_log.jcloude_webhook_log.get_permission_query_conditions",
	"SQL Playground Log": "jcloude.jcloude.pagetype.sql_playground_log.sql_playground_log.get_permission_query_conditions",
	"Site Database User": "jcloude.jcloude.pagetype.site_database_user.site_database_user.get_permission_query_conditions",
	"Server Snapshot": "jcloude.jcloude.pagetype.server_snapshot.server_snapshot.get_permission_query_conditions",
	"Server Snapshot Recovery": "jcloude.jcloude.pagetype.server_snapshot_recovery.server_snapshot_recovery.get_permission_query_conditions",
}
has_permission = {
	"Site": "jcloude.overrides.has_permission",
	"Site Backup": "jcloude.overrides.has_permission",
	"Site Domain": "jcloude.overrides.has_permission",
	"TLS Certificate": "jcloude.overrides.has_permission",
	"Team": "jcloude.jcloude.pagetype.team.team.has_permission",
	"Subscription": "jcloude.overrides.has_permission",
	"Stripe Payment Method": "jcloude.overrides.has_permission",
	"Balance Transaction": "jcloude.overrides.has_permission",
	"Invoice": "jcloude.jcloude.pagetype.invoice.invoice.has_permission",
	"App Source": "jcloude.overrides.has_permission",
	"App Release": "jcloude.jcloude.pagetype.app_release.app_release.has_permission",
	"Release Group": "jcloude.overrides.has_permission",
	"Deploy Candidate": "jcloude.overrides.has_permission",
	"Deploy Candidate Difference": "jcloude.overrides.has_permission",
	"Deploy": "jcloude.overrides.has_permission",
	"Bench": "jcloude.overrides.has_permission",
	"Server": "jcloude.overrides.has_permission",
	"Database Server": "jcloude.overrides.has_permission",
	"Jcloude Webhook": "jcloude.overrides.has_permission",
	"Jcloude Webhook Log": "jcloude.overrides.has_permission",
	"Jcloude Webhook Attempt": "jcloude.jcloude.pagetype.jcloude_webhook_attempt.jcloude_webhook_attempt.has_permission",
	"SQL Playground Log": "jcloude.overrides.has_permission",
	"Site Database User": "jcloude.overrides.has_permission",
	"Server Snapshot": "jcloude.overrides.has_permission",
	"Server Snapshot Recovery": "jcloude.overrides.has_permission",
}

# Page Events
# ---------------
# Hook on document methods and events

pg_events = {
	"Stripe Webhook Log": {
		"after_insert": [
			"jcloude.jcloude.pagetype.invoice.stripe_webhook_handler.handle_stripe_webhook_events",
			"jcloude.jcloude.pagetype.team.team.process_stripe_webhook",
		],
	},
	"Address": {"validate": "jcloude.api.billing.validate_gst"},
	"Site": {
		"before_insert": "jcloude.jcloude.pagetype.team.team.validate_site_creation",
		"after_insert": "jcloude.jcloude.pagetype.jcloude_role.jcloude_role.create_user_resource",
	},
	"Marketplace App Subscription": {
		"on_update": "jcloude.jcloude.pagetype.storage_integration_subscription.storage_integration_subscription.create_after_insert",
	},
	"Release Group": {
		"after_insert": "jcloude.jcloude.pagetype.jcloude_role.jcloude_role.create_user_resource",
	},
	"Server": {
		"after_insert": "jcloude.jcloude.pagetype.jcloude_role.jcloude_role.create_user_resource",
	},
}

# Scheduled Tasks
# ---------------

scheduler_events = {
	"weekly_long": ["jcloude.jcloude.pagetype.marketplace_app.events.auto_review_for_missing_steps"],
	"daily": [
		"jcloude.experimental.pagetype.referral_bonus.referral_bonus.credit_referral_bonuses",
		"jcloude.jcloude.pagetype.log_counter.log_counter.record_counts",
		"jcloude.jcloude.pagetype.incident.incident.notify_ignored_servers",
		"jcloude.jcloude.pagetype.database_server.database_server.unindex_mariadb_binlogs",
		"jcloude.jcloude.pagetype.database_server.database_server.remove_uploaded_binlogs_from_disk",
		"jcloude.jcloude.pagetype.database_server.database_server.remove_uploaded_binlogs_from_s3",
		"jcloude.jcloude.pagetype.mariadb_binlog.mariadb_binlog.cleanup_old_records",
		"jcloude.jcloude.pagetype.database_server.database_server.delete_mariadb_binlog_for_archived_servers",
		"jcloude.jcloude.pagetype.team.team.check_budget_alerts",
	],
	"daily_long": [
		"jcloude.jcloude.audit.check_bench_fields",
		"jcloude.jcloude.audit.check_offsite_backups",
		"jcloude.jcloude.audit.plan_audit",
		"jcloude.jcloude.audit.check_app_server_replica_benches",
		"jcloude.jcloude.pagetype.invoice.invoice.finalize_unpaid_prepaid_credit_invoices",
		"jcloude.jcloude.pagetype.bench.bench.sync_analytics",
		"jcloude.saas.pagetype.saas_app_subscription.saas_app_subscription.suspend_prepaid_subscriptions",
		"jcloude.jcloude.pagetype.backup_restoration_test.backup_test.archive_backup_test_sites",
		"jcloude.jcloude.pagetype.payout_order.payout_order.create_marketplace_payout_orders",
		"jcloude.jcloude.pagetype.root_domain.root_domain.cleanup_cname_records",
		"jcloude.jcloude.pagetype.remote_file.remote_file.poll_file_statuses",
		"jcloude.jcloude.pagetype.site_domain.site_domain.update_dns_type",
		"jcloude.jcloude.pagetype.jcloude_webhook_log.jcloude_webhook_log.clean_logs_older_than_24_hours",
		"jcloude.jcloude.pagetype.payment_due_extension.payment_due_extension.remove_payment_due_extension",
		"jcloude.jcloude.pagetype.tls_certificate.tls_certificate.notify_custom_tls_renewal",
		"jcloude.jcloude.pagetype.site.site.suspend_sites_exceeding_disk_usage_for_last_14_days",
		"jcloude.jcloude.pagetype.user_2fa.user_2fa.yearly_2fa_recovery_code_reminder",
		"jcloude.jcloude.pagetype.registry_server.registry_server.delete_old_images_from_registry",
		"jcloude.saas.pagetype.product_trial_request.product_trial_request.gather_daily_stats",
		"jcloude.jcloude.pagetype.agent_job.agent_job.agent_poll_count_stats_daily",
	],
	"hourly": [
		"jcloude.jcloude.pagetype.site.backups.cleanup_local",
		"jcloude.jcloude.pagetype.agent_job.agent_job.update_job_step_status",
		"jcloude.jcloude.pagetype.bench.bench.archive_obsolete_benches",
		"jcloude.jcloude.pagetype.site.backups.schedule_logical_backups_for_sites_with_backup_time",
		"jcloude.jcloude.pagetype.site.backups.schedule_physical_backups_for_sites_with_backup_time",
		"jcloude.jcloude.pagetype.tls_certificate.tls_certificate.renew_tls_certificates",
		"jcloude.saas.pagetype.product_trial_request.product_trial_request.expire_long_pending_trial_requests",
		"jcloude.overrides.cleanup_ansible_tmp_files",
		"jcloude.jcloude.pagetype.site.site.archive_suspended_sites",
		"jcloude.jcloude.pagetype.site.site.send_warning_mail_regarding_sites_exceeding_disk_usage",
		"jcloude.jcloude.pagetype.add_on_storage_log.add_on_storage_log.send_disk_extention_notification",
		"jcloude.jcloude.pagetype.server_snapshot_recovery.server_snapshot_recovery.expire_backups",
		"jcloude.jcloude.pagetype.server_snapshot.server_snapshot.expire_snapshots",
		"jcloude.saas.pagetype.product_trial.product_trial.sync_product_site_users",
		"jcloude.jcloude.pagetype.database_server.database_server.sync_binlogs_info",
	],
	"hourly_long": [
		"jcloude.jcloude.pagetype.release_group.release_group.prune_servers_without_sites",
		"jcloude.jcloude.pagetype.release_group.release_group.add_public_servers_to_public_groups",
		"jcloude.jcloude.pagetype.server.server.scale_workers",
		"jcloude.jcloude.pagetype.usage_record.usage_record.link_unlinked_usage_records",
		"jcloude.jcloude.pagetype.bench.bench.sync_benches",
		"jcloude.jcloude.pagetype.invoice.invoice.finalize_draft_invoices",
		"jcloude.jcloude.pagetype.agent_job.agent_job.fail_old_jobs",
		"jcloude.jcloude.pagetype.jcloude_job.jcloude_job.fail_stuck_jcloude_jobs",
		"jcloude.jcloude.pagetype.site_update.site_update.mark_stuck_updates_as_fatal",
		"jcloude.jcloude.pagetype.deploy_candidate_build.deploy_candidate_build.cleanup_build_directories",
		"jcloude.jcloude.pagetype.deploy_candidate_build.deploy_candidate_build.check_builds_status",
		"jcloude.jcloude.pagetype.virtual_machine.virtual_machine.snapshot_oci_virtual_machines",
		"jcloude.jcloude.pagetype.virtual_machine.virtual_machine.snapshot_aws_internal_virtual_machines",
		"jcloude.jcloude.pagetype.virtual_disk_snapshot.virtual_disk_snapshot.delete_old_snapshots",
		"jcloude.jcloude.pagetype.virtual_disk_snapshot.virtual_disk_snapshot.delete_expired_snapshots",
		"jcloude.jcloude.pagetype.app_release.app_release.cleanup_unused_releases",
		"jcloude.jcloude.pagetype.jcloude_webhook.jcloude_webhook.auto_disable_high_delivery_failure_webhooks",
		"jcloude.saas.pagetype.product_trial_request.product_trial_request.gather_hourly_stats",
		"jcloude.jcloude.pagetype.agent_job.agent_job.agent_poll_count_stats_hourly",
	],
	"all": [
		"jcloude.auth.flush",
		"jcloude.jcloude.pagetype.site.sync.sync_setup_wizard_status",
		"jcloude.jcloude.pagetype.site.archive.archive_suspended_trial_sites",
		"jcloude.jcloude.pagetype.agent_job.agent_job.flush",
	],
	"cron": {
		"1-59/2 * * * *": [
			"jcloude.jcloude.pagetype.incident.incident.validate_incidents",
		],
		"*/2 * * * *": [
			"jcloude.jcloude.pagetype.incident.incident.resolve_incidents",
		],
		"45 * * * *": [
			"jcloude.jcloude.pagetype.database_server.database_server.update_database_schema_sizes",
		],
		"0 4 * * *": [
			"jcloude.jcloude.pagetype.site.backups.cleanup_offsite",
			"jcloude.jcloude.pagetype.site.backups.expire_physical",
			"jcloude.jcloude.cleanup.unlink_remote_files_from_site",
		],
		"10 0 * * *": [
			"jcloude.jcloude.audit.check_backup_records",
			"jcloude.jcloude.audit.billing_audit",
		],
		"0 3 * * *": [
			"jcloude.jcloude.pagetype.drip_email.drip_email.send_drip_emails",
			"jcloude.jcloude.pagetype.virtual_disk_snapshot.virtual_disk_snapshot.sync_all_snapshots_from_aws",
		],
		"* * * * * 0/5": [
			"jcloude.jcloude.pagetype.agent_job.agent_job.poll_pending_jobs",
			"jcloude.jcloude.pagetype.jcloude_webhook_log.jcloude_webhook_log.process",
			"jcloude.jcloude.pagetype.telegram_message.telegram_message.send_telegram_message",
			"jcloude.jcloude.pagetype.agent_update.agent_update.process_bulk_agent_update",
			"jcloude.jcloude.pagetype.jcloude_job.jcloude_job.process_failed_callbacks",
			"jcloude.jcloude.pagetype.server_snapshot_recovery.server_snapshot_recovery.resume_warmed_up_restorations",
			"jcloude.jcloude.pagetype.server_snapshot.server_snapshot.move_pending_snapshots_to_processing",
		],
		"* * * * * 0/30": [
			"jcloude.jcloude.pagetype.account_request.account_request.expire_request_key",
			"jcloude.jcloude.pagetype.physical_backup_restoration.physical_backup_restoration.process_scheduled_restorations",
		],
		"0 */2 * * *": [
			"jcloude.signup_e2e.run_signup_e2e",
		],
		"0 */6 * * *": [
			"jcloude.jcloude.pagetype.server.server.cleanup_unused_files",
			"jcloude.jcloude.pagetype.razorpay_payment_record.razorpay_payment_record.fetch_pending_payment_orders",
		],
		"*/15 * * * *": [
			"jcloude.jcloude.pagetype.site_update.site_update.schedule_updates",
			"jcloude.jcloude.pagetype.site.backups.schedule_logical_backups",
			"jcloude.jcloude.pagetype.site.backups.schedule_physical_backups",
			"jcloude.jcloude.pagetype.site_migration.site_migration.run_scheduled_migrations",
			"jcloude.jcloude.pagetype.version_upgrade.version_upgrade.run_scheduled_upgrades",
			"jcloude.jcloude.pagetype.subscription.subscription.create_usage_records",
			"jcloude.jcloude.pagetype.virtual_machine.virtual_machine.sync_virtual_machines",
			"jcloude.jcloude.pagetype.mariadb_stalk.mariadb_stalk.fetch_stalks",
			"jcloude.jcloude.pagetype.virtual_machine.virtual_machine.rolling_snapshot_database_server_virtual_machines",
			"jcloude.infrastructure.pagetype.virtual_disk_resize.virtual_disk_resize.run_scheduled_resizes",
		],
		"*/5 * * * *": [
			"jcloude.jcloude.pagetype.version_upgrade.version_upgrade.update_from_site_update",
			"jcloude.jcloude.pagetype.site_replication.site_replication.update_from_site",
			"jcloude.jcloude.pagetype.virtual_disk_snapshot.virtual_disk_snapshot.sync_snapshots",
			"jcloude.jcloude.pagetype.site.site.sync_sites_setup_wizard_complete_status",
			"jcloude.jcloude.pagetype.drip_email.drip_email.send_welcome_email",
			"jcloude.jcloude.pagetype.site_update.site_update.run_scheduled_updates",
			"jcloude.jcloude.pagetype.virtual_machine.virtual_machine.snapshot_aws_servers",
			"jcloude.jcloude.pagetype.app.app.poll_new_releases",
			"jcloude.utils.jobs.alert_on_zombie_rq_jobs",
			"jcloude.saas.pagetype.product_trial.product_trial.replenish_standby_sites",
		],
		"* * * * *": [
			"jcloude.jcloude.pagetype.virtual_disk_snapshot.virtual_disk_snapshot.sync_physical_backup_snapshots",
			"jcloude.jcloude.pagetype.deploy_candidate_build.deploy_candidate_build.run_scheduled_builds",
			"jcloude.jcloude.pagetype.agent_request_failure.agent_request_failure.remove_old_failures",
			"jcloude.saas.pagetype.site_access_token.site_access_token.cleanup_expired_access_tokens",
			"jcloude.jcloude.pagetype.server_snapshot.server_snapshot.sync_ongoing_server_snapshots",
			"jcloude.jcloude.pagetype.site.site.create_subscription_for_trial_sites",
			"jcloude.jcloude.pagetype.monitor_server.monitor_server.check_monitoring_servers_rate_limit_key",
			"jcloude.jcloude.pagetype.auto_scale_record.auto_scale_record.run_scheduled_scale_records",
		],
		"*/10 * * * *": [
			"jcloude.jcloude.pagetype.site.saas_pool.create",
			"jcloude.jcloude.pagetype.virtual_disk_snapshot.virtual_disk_snapshot.sync_rolling_snapshots",
			"jcloude.jcloude.pagetype.database_server.database_server.auto_purge_binlogs_by_size_limit",
		],
		"*/30 * * * *": [
			"jcloude.jcloude.pagetype.site_update.scheduled_auto_updates.trigger",
			"jcloude.jcloude.pagetype.team.suspend_sites.execute",
		],
		"15,45 * * * *": [
			"jcloude.jcloude.pagetype.site.site_usages.update_cpu_usages",
			"jcloude.jcloude.pagetype.site.site_usages.update_disk_usages",
		],
		"15 2,4 * * *": [
			"jcloude.jcloude.pagetype.team_deletion_request.team_deletion_request.process_team_deletion_requests",
		],
		"0 0 1 */3 *": ["jcloude.jcloude.pagetype.backup_restoration_test.backup_test.run_backup_restore_test"],
		"0 8 * * *": [
			"jcloude.jcloude.pagetype.aws_savings_plan_recommendation.aws_savings_plan_recommendation.create",
			"jcloude.jcloude.cleanup.reset_large_output_fields_from_ansible_tasks",
		],
		"0 21 * * *": [
			"jcloude.jcloude.audit.partner_billing_audit",
		],
		"0 6 * * *": [
			"jcloude.jcloude.audit.suspend_sites_with_disabled_team",
			"jcloude.jcloude.pagetype.tls_certificate.tls_certificate.retrigger_failed_wildcard_tls_callbacks",
			"jcloude.jcloude.pagetype.aws_savings_plan_recommendation.aws_savings_plan_recommendation.refresh",
			"jcloude.infrastructure.pagetype.ssh_access_audit.ssh_access_audit.run",
		],
		"0 9 * * 2": [
			"jcloude.jcloude.pagetype.build_metric.build_metric.create_build_metric",
			"jcloude.saas.pagetype.product_trial_request.product_trial_request.gather_weekly_stats",
		],
	},
}

deploy_hours = [1, 2, 3, 4, 5, 21, 22, 23]  # Purposefully avoiding 0

fixtures = [
	"Agent Job Type",
	"Jcloude Job Type",
	"Jingrow Version",
	"MariaDB Variable",
	"Cloud Region",
	{"dt": "Role", "filters": [["role_name", "like", "Jcloude%"]]},
	"Site Config Key Blacklist",
	"Jcloude Method Permission",
	"Bench Dependency",
	"Server Storage Plan",
	"Server Snapshot Plan",
	"Jcloude Webhook Event",
]
# Testing
# -------

before_tests = "jcloude.tests.before_test.execute"

# Overriding Methods
# ------------------------------
#
override_whitelisted_methods = {"upload_file": "jcloude.overrides.upload_file"}
#
# each overriding function accepts a `data` argument;
# generated from the base implementation of the pagetype dashboard,
# along with any modifications made in other Jingrow apps
# override_pagetype_dashboards = {
# 	"Task": "jcloude.task.get_dashboard_data"
# }

override_pagetype_class = {"User": "jcloude.overrides.CustomUser"}

on_session_creation = "jcloude.overrides.on_session_creation"
# on_logout = "jcloude.overrides.on_logout"
on_login = "jcloude.overrides.on_login"

before_request = "jcloude.overrides.before_request"
before_job = "jcloude.overrides.before_job"
# after_job = "jcloude.overrides.after_job"

# Data Deletion Privacy Docs

user_data_fields = [
	{"pagetype": "Team", "strict": True},
]

auth_hooks = ["jcloude.auth.hook"]

page_renderer = ["jcloude.metrics.MetricsRenderer"]

export_python_type_annotations = True

default_log_clearing_pagetypes = {
	"Alertmanager Webhook Log": 60,
}


# These are used for some business logic, they should be manually evicted.
__persistent_cache_keys = [
	"agent-jobs",
	"monitor-transactions",
	"google_oauth_flow*",
	"fc_oauth_state*",
	"one_time_login_key*",
	"jcloude-auth-logs",
	"rl:*",
]

# `jingrow.rename_pg` erases all caches, this hook preserves some of them.
# Note:
# - These are only "most used" cache keys. This lessens the impact of renames but doesn't eliminate them.
# - Adding more keys here will slow down `jingrow.clear_cache` but it's "rare" enough.
# - This also means that other "valid" jingrow.clear_cache() usage won't clear these keys!
# - Use jingrow.cache.flushall() instead.
persistent_cache_keys = [
	*__persistent_cache_keys,
	"agent_job_step_output",
	"all_apps",
	"app_hooks",
	"assets_json",
	"assignment_rule_map",
	"bootinfo",
	"builder.builder*",  # path resolution, it has its own cache eviction.
	"db_tables",
	"defaults",
	"pagetype_form_meta",
	"pagetype_meta",
	"pagetypes_with_web_view",
	"document_cache::*",
	"document_naming_rule_map",
	"domain_restricted_pagetypes",
	"domain_restricted_pages",
	"energy_point_rule_map",
	"jingrow.utils.scheduler.schedule_jobs_based_on_activity*",  # dormant checks
	"jingrow.website.page_renderers*",  # FW's routing
	"home_page",
	"information_schema:counts",
	"installed_app_modules",
	"ip_country_map",
	"is_table",
	"languages",
	"last_db_session_update",
	"marketplace_apps",
	"merged_translations",
	"metadata_version",
	"server_script_map",  # Routing and actual server scripts
	"session",
	"table_columns",
	"website_page",
	"website_route_rules",
]

before_migrate = ["jcloude.overrides.before_after_migrate"]
after_migrate = ["jcloude.overrides.before_after_migrate"]
