mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
set 6 month retention for hobby users
Some checks are pending
Node.js CI / build (postgresql, 18.18, 10) (push) Waiting to run
Some checks are pending
Node.js CI / build (postgresql, 18.18, 10) (push) Waiting to run
This commit is contained in:
parent
b75c15dc43
commit
37b6194c5f
2 changed files with 23 additions and 1 deletions
|
|
@ -38,3 +38,15 @@ export async function fetchSession(websiteId: string, sessionId: string): Promis
|
||||||
|
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function fetchAccount(websiteId: string) {
|
||||||
|
let account = null;
|
||||||
|
|
||||||
|
const cache = await redis.client.get(`cache:website:${websiteId}`);
|
||||||
|
|
||||||
|
if (cache) {
|
||||||
|
account = await redis.client.get(`account:${cache.account_id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
|
import { startOfMonth, subMonths } from 'date-fns';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { checkAuth } from '@/lib/auth';
|
import { checkAuth } from '@/lib/auth';
|
||||||
import { DEFAULT_PAGE_SIZE, FILTER_COLUMNS } from '@/lib/constants';
|
import { DEFAULT_PAGE_SIZE, FILTER_COLUMNS } from '@/lib/constants';
|
||||||
import { getAllowedUnits, getMinimumUnit, maxDate, parseDateRange } from '@/lib/date';
|
import { getAllowedUnits, getMinimumUnit, maxDate, parseDateRange } from '@/lib/date';
|
||||||
import { fetchWebsite } from '@/lib/load';
|
import { fetchAccount, fetchWebsite } from '@/lib/load';
|
||||||
import { filtersArrayToObject } from '@/lib/params';
|
import { filtersArrayToObject } from '@/lib/params';
|
||||||
import { badRequest, unauthorized } from '@/lib/response';
|
import { badRequest, unauthorized } from '@/lib/response';
|
||||||
import type { QueryFilters } from '@/lib/types';
|
import type { QueryFilters } from '@/lib/types';
|
||||||
|
|
@ -82,6 +83,15 @@ export function getRequestFilters(query: Record<string, any>) {
|
||||||
|
|
||||||
export async function setWebsiteDate(websiteId: string, data: Record<string, any>) {
|
export async function setWebsiteDate(websiteId: string, data: Record<string, any>) {
|
||||||
const website = await fetchWebsite(websiteId);
|
const website = await fetchWebsite(websiteId);
|
||||||
|
const cloudMode = !!process.env.CLOUD_MODE;
|
||||||
|
|
||||||
|
if (cloudMode) {
|
||||||
|
const account = await fetchAccount(websiteId);
|
||||||
|
|
||||||
|
if (!account?.hasSubscription) {
|
||||||
|
data.startDate = maxDate(data.startDate, startOfMonth(subMonths(new Date(), 6)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (website?.resetAt) {
|
if (website?.resetAt) {
|
||||||
data.startDate = maxDate(data.startDate, new Date(website?.resetAt));
|
data.startDate = maxDate(data.startDate, new Date(website?.resetAt));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue