Implement previous year delete

This commit is contained in:
Owen
2025-12-06 20:49:30 -05:00
parent d7e06161a8
commit e24a13fb11
9 changed files with 242 additions and 21 deletions

View File

@@ -16,6 +16,7 @@ import { getCountryCodeForIp } from "@server/lib/geoip";
import logger from "@server/logger";
import { and, eq, lt } from "drizzle-orm";
import cache from "@server/lib/cache";
import { calculateCutoffTimestamp } from "@server/lib/cleanupLogs";
async function getAccessDays(orgId: string): Promise<number> {
// check cache first
@@ -47,9 +48,7 @@ async function getAccessDays(orgId: string): Promise<number> {
}
export async function cleanUpOldLogs(orgId: string, retentionDays: number) {
const now = Math.floor(Date.now() / 1000);
const cutoffTimestamp = now - retentionDays * 24 * 60 * 60;
const cutoffTimestamp = calculateCutoffTimestamp(retentionDays);
try {
await db

View File

@@ -19,6 +19,7 @@ import { Request, Response, NextFunction } from "express";
import createHttpError from "http-errors";
import { and, eq, lt } from "drizzle-orm";
import cache from "@server/lib/cache";
import { calculateCutoffTimestamp } from "@server/lib/cleanupLogs";
async function getActionDays(orgId: string): Promise<number> {
// check cache first
@@ -46,9 +47,7 @@ async function getActionDays(orgId: string): Promise<number> {
}
export async function cleanUpOldLogs(orgId: string, retentionDays: number) {
const now = Math.floor(Date.now() / 1000);
const cutoffTimestamp = now - retentionDays * 24 * 60 * 60;
const cutoffTimestamp = calculateCutoffTimestamp(retentionDays);
try {
await db