From 655a68a847a18bf788fc3d58ae028a396ffa2214 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 20 May 2023 11:07:53 +0200 Subject: [PATCH] Feature/change uptime to last 90 days (#1993) * Change uptime to last 90 days * Update changelog --- CHANGELOG.md | 1 + apps/api/src/app/info/info.service.ts | 8 ++++++-- apps/client/src/app/pages/open/open-page.html | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87ee49484..695f93110 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Improved the local number formatting in the value component +- Changed the uptime to the last 90 days on the _Open Startup_ (`/open`) page ### Fixed diff --git a/apps/api/src/app/info/info.service.ts b/apps/api/src/app/info/info.service.ts index 8af8e6ee2..187135a35 100644 --- a/apps/api/src/app/info/info.service.ts +++ b/apps/api/src/app/info/info.service.ts @@ -17,6 +17,7 @@ import { ghostfolioFearAndGreedIndexDataSource } from '@ghostfolio/common/config'; import { + DATE_FORMAT, encodeDataSource, extractNumberFromString } from '@ghostfolio/common/helper'; @@ -31,7 +32,7 @@ import { Injectable, Logger } from '@nestjs/common'; import { JwtService } from '@nestjs/jwt'; import * as bent from 'bent'; import * as cheerio from 'cheerio'; -import { subDays } from 'date-fns'; +import { format, subDays } from 'date-fns'; @Injectable() export class InfoService { @@ -346,7 +347,10 @@ export class InfoService { )) as string; const get = bent( - `https://betteruptime.com/api/v2/monitors/${monitorId}/sla`, + `https://betteruptime.com/api/v2/monitors/${monitorId}/sla?from=${format( + subDays(new Date(), 90), + DATE_FORMAT + )}&to${format(new Date(), DATE_FORMAT)}`, 'GET', 'json', 200, diff --git a/apps/client/src/app/pages/open/open-page.html b/apps/client/src/app/pages/open/open-page.html index 81b4dcd4e..62503e387 100644 --- a/apps/client/src/app/pages/open/open-page.html +++ b/apps/client/src/app/pages/open/open-page.html @@ -109,6 +109,7 @@