# Copyright (c) 2018, JINGROW
# License: MIT. See LICENSE

import jingrow
from jingrow.model.page import Page


class ViewLog(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

		reference_pagetype: DF.Link | None
		reference_name: DF.DynamicLink | None
		viewed_by: DF.Data | None

	# end: auto-generated types
	@staticmethod
	def clear_old_logs(days=180):
		from jingrow.query_builder import Interval
		from jingrow.query_builder.functions import Now

		table = jingrow.qb.PageType("View Log")
		jingrow.db.delete(table, filters=(table.modified < (Now() - Interval(days=days))))
