|
|
@ -8,6 +8,7 @@ import { PropertyService } from '@ghostfolio/api/services/property/property.serv |
|
|
|
import { TagService } from '@ghostfolio/api/services/tag/tag.service'; |
|
|
|
import { |
|
|
|
DEFAULT_CURRENCY, |
|
|
|
DEFAULT_REQUEST_TIMEOUT, |
|
|
|
PROPERTY_BETTER_UPTIME_MONITOR_ID, |
|
|
|
PROPERTY_COUNTRIES_OF_SUBSCRIBERS, |
|
|
|
PROPERTY_DEMO_USER_ID, |
|
|
@ -168,10 +169,18 @@ export class InfoService { |
|
|
|
|
|
|
|
private async countDockerHubPulls(): Promise<number> { |
|
|
|
try { |
|
|
|
const abortController = new AbortController(); |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
abortController.abort(); |
|
|
|
}, DEFAULT_REQUEST_TIMEOUT); |
|
|
|
|
|
|
|
const { pull_count } = await got( |
|
|
|
`https://hub.docker.com/v2/repositories/ghostfolio/ghostfolio`, |
|
|
|
{ |
|
|
|
headers: { 'User-Agent': 'request' } |
|
|
|
headers: { 'User-Agent': 'request' }, |
|
|
|
// @ts-ignore
|
|
|
|
signal: abortController.signal |
|
|
|
} |
|
|
|
).json<any>(); |
|
|
|
|
|
|
@ -185,7 +194,16 @@ export class InfoService { |
|
|
|
|
|
|
|
private async countGitHubContributors(): Promise<number> { |
|
|
|
try { |
|
|
|
const { body } = await got('https://github.com/ghostfolio/ghostfolio'); |
|
|
|
const abortController = new AbortController(); |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
abortController.abort(); |
|
|
|
}, DEFAULT_REQUEST_TIMEOUT); |
|
|
|
|
|
|
|
const { body } = await got('https://github.com/ghostfolio/ghostfolio', { |
|
|
|
// @ts-ignore
|
|
|
|
signal: abortController.signal |
|
|
|
}); |
|
|
|
|
|
|
|
const $ = cheerio.load(body); |
|
|
|
|
|
|
@ -203,10 +221,18 @@ export class InfoService { |
|
|
|
|
|
|
|
private async countGitHubStargazers(): Promise<number> { |
|
|
|
try { |
|
|
|
const abortController = new AbortController(); |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
abortController.abort(); |
|
|
|
}, DEFAULT_REQUEST_TIMEOUT); |
|
|
|
|
|
|
|
const { stargazers_count } = await got( |
|
|
|
`https://api.github.com/repos/ghostfolio/ghostfolio`, |
|
|
|
{ |
|
|
|
headers: { 'User-Agent': 'request' } |
|
|
|
headers: { 'User-Agent': 'request' }, |
|
|
|
// @ts-ignore
|
|
|
|
signal: abortController.signal |
|
|
|
} |
|
|
|
).json<any>(); |
|
|
|
|
|
|
@ -323,18 +349,25 @@ export class InfoService { |
|
|
|
PROPERTY_BETTER_UPTIME_MONITOR_ID |
|
|
|
)) as string; |
|
|
|
|
|
|
|
const abortController = new AbortController(); |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
abortController.abort(); |
|
|
|
}, DEFAULT_REQUEST_TIMEOUT); |
|
|
|
|
|
|
|
const { data } = await got( |
|
|
|
`https://uptime.betterstack.com/api/v2/monitors/${monitorId}/sla?from=${format( |
|
|
|
subDays(new Date(), 90), |
|
|
|
DATE_FORMAT |
|
|
|
)}&to${format(new Date(), DATE_FORMAT)}`,
|
|
|
|
|
|
|
|
{ |
|
|
|
headers: { |
|
|
|
Authorization: `Bearer ${this.configurationService.get( |
|
|
|
'BETTER_UPTIME_API_KEY' |
|
|
|
)}` |
|
|
|
} |
|
|
|
}, |
|
|
|
// @ts-ignore
|
|
|
|
signal: abortController.signal |
|
|
|
} |
|
|
|
).json<any>(); |
|
|
|
|
|
|
|