From cd0db7df7a49a05fbe68a9bf89c293acd410adc5 Mon Sep 17 00:00:00 2001 From: MohammadHasan Akbari Date: Tue, 25 Jun 2024 18:26:58 +0330 Subject: [PATCH] fix: dynamic max since --- src/commands/app/logs.ts | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/commands/app/logs.ts b/src/commands/app/logs.ts index 95f8bed..6aff8f2 100644 --- a/src/commands/app/logs.ts +++ b/src/commands/app/logs.ts @@ -78,29 +78,19 @@ export default class AppLogs extends Command { flags.app || projectConfig.app || (await this.promptProject()); const { - project: { bundlePlanID, network }, + project: { planID, bundlePlanID, network }, } = await this.got( `v1/projects/${project}`, ).json(); - let maxSince: number; - switch (bundlePlanID) { - case 'free': - maxSince = now - 3600; // 1 hour - break; - case 'standard': - maxSince = now - 2592000; // 30 days - break; - case 'pro': - maxSince = now - 5184000; // 60 days - break; - default: - maxSince = now - 3600; // 1 hour ago - } + const { plans } = await this.got('v1/me').json<{ plans: any }>(); - if (!network) { - maxSince = now - 604800; // 7 days ago for projects on legacy infra - } + const maxSince: number = + now - + (network + ? plans.projectBundlePlans[planID][bundlePlanID].maxLogsRetention * + 86400 + : plans.projectBundlePlans.g1.default.maxLogsRetention * 86400); const start: number = flags.since ? this.getStart(`${flags.since}`)