1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-06-27 01:19:00 +02:00

chore: adjust reminder days (#9810)

This commit is contained in:
Mateusz Kwasniewski 2025-04-22 12:29:07 +02:00 committed by GitHub
parent 150a044207
commit a22f5d0201
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 4 deletions

View File

@ -34,6 +34,9 @@ const ActionsBox = styled(Box)(({ theme }) => ({
type ReminderType = 'complete' | 'removeCode' | 'archive' | null;
export const COMPLETE_REMINDER_DAYS = 30;
export const REMOVE_CODE_REMINDER_DAYS = 3;
export const CleanupReminder: FC<{
feature: IFeatureToggle;
onChange: () => void;
@ -62,7 +65,10 @@ export const CleanupReminder: FC<{
const determineReminder = (): ReminderType => {
if (!currentStage || !isRelevantType) return null;
if (currentStage.name === 'live' && daysInStage > 30) {
if (
currentStage.name === 'live' &&
daysInStage > COMPLETE_REMINDER_DAYS
) {
return 'complete';
}
if (
@ -72,7 +78,7 @@ export const CleanupReminder: FC<{
if (isSafeToArchive(currentStage.environments)) {
return 'archive';
}
if (daysInStage > 2) {
if (daysInStage > REMOVE_CODE_REMINDER_DAYS) {
return 'removeCode';
}
}

View File

@ -1,13 +1,16 @@
import { isBefore, parseISO, subDays } from 'date-fns';
// no metrics received in this period
const SAFE_TO_ARCHIVE_DAYS = 2;
export function isSafeToArchive(
environments: Array<{ name: string; lastSeenAt: string }>,
) {
const twoDaysAgo = subDays(new Date(), 2);
const daysAgo = subDays(new Date(), SAFE_TO_ARCHIVE_DAYS);
return environments.every((env) => {
const lastSeenDate = parseISO(env.lastSeenAt);
return isBefore(lastSeenDate, twoDaysAgo);
return isBefore(lastSeenDate, daysAgo);
});
}