# -*- coding: utf-8 -*-
# Copyright (c) 2020, JINGROW
# For license information, please see license.txt


import jingrow
from jingrow.model.page import Page
from jingrow.query_builder import Interval
from jingrow.query_builder.functions import Now


class SiteUsage(Page):
	# begin: auto-generated types
	# This code is auto-generated. Do not modify anything in this block.

	from typing import TYPE_CHECKING

	if TYPE_CHECKING:
		from jingrow.types import DF

		backups: DF.Int
		database: DF.Int
		database_free: DF.Int
		database_free_tables: DF.Code | None
		private: DF.Int
		public: DF.Int
		site: DF.Link | None
	# end: auto-generated types

	@staticmethod
	def clear_old_logs(days=60):
		table = jingrow.qb.PageType("Site Usage")
		jingrow.db.delete(table, filters=(table.creation < (Now() - Interval(days=days))))
