Browse Source
Feature/add contributors count to statistics (#342)
* Add contributors count to statistics
* Update changelog
pull/344/head
Thomas Kaul
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
46 additions and
6 deletions
-
CHANGELOG.md
-
apps/api/src/app/info/info.service.ts
-
apps/client/src/app/pages/about/about-page.html
-
libs/common/src/lib/interfaces/statistics.interface.ts
|
|
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. |
|
|
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), |
|
|
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
|
|
|
|
|
|
|
## Unreleased |
|
|
|
|
|
|
|
### Added |
|
|
|
|
|
|
|
- Extended the statistics section on the about page by the _GitHub_ contributors count |
|
|
|
|
|
|
|
## 1.45.0 - 04.09.2021 |
|
|
|
|
|
|
|
### Added |
|
|
|
|
|
@ -90,6 +90,27 @@ export class InfoService { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private async countGitHubContributors(): Promise<number> { |
|
|
|
try { |
|
|
|
const get = bent( |
|
|
|
`https://api.github.com/repos/ghostfolio/ghostfolio/contributors`, |
|
|
|
'GET', |
|
|
|
'json', |
|
|
|
200, |
|
|
|
{ |
|
|
|
'User-Agent': 'request' |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
|
const contributors = await get(); |
|
|
|
return contributors?.length; |
|
|
|
} catch (error) { |
|
|
|
console.error(error); |
|
|
|
|
|
|
|
return undefined; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private async countGitHubStargazers(): Promise<number> { |
|
|
|
try { |
|
|
|
const get = bent( |
|
|
@ -131,11 +152,13 @@ export class InfoService { |
|
|
|
|
|
|
|
const activeUsers1d = await this.countActiveUsers(1); |
|
|
|
const activeUsers30d = await this.countActiveUsers(30); |
|
|
|
const gitHubContributors = await this.countGitHubContributors(); |
|
|
|
const gitHubStargazers = await this.countGitHubStargazers(); |
|
|
|
|
|
|
|
return { |
|
|
|
activeUsers1d, |
|
|
|
activeUsers30d, |
|
|
|
gitHubContributors, |
|
|
|
gitHubStargazers |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
@ -94,27 +94,37 @@ |
|
|
|
<mat-card> |
|
|
|
<mat-card-content> |
|
|
|
<div class="row"> |
|
|
|
<div class="col-xs-12 col-md-4 my-2"> |
|
|
|
<div class="col-xs-12 col-md-3 my-2"> |
|
|
|
<h3 class="mb-0" [hidden]="!statistics?.activeUsers1d"> |
|
|
|
{{ statistics?.activeUsers1d ?? '-' }} |
|
|
|
</h3> |
|
|
|
<div class="h6 mb-0"> |
|
|
|
Active Users <small class="text-muted">(Last 24 hours)</small> |
|
|
|
<span i18n>Active Users</span> <small class="text-muted" |
|
|
|
>(Last 24 hours)</small |
|
|
|
> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="col-xs-12 col-md-4 my-2"> |
|
|
|
<div class="col-xs-12 col-md-3 my-2"> |
|
|
|
<h3 class="mb-0" [hidden]="!statistics?.activeUsers30d"> |
|
|
|
{{ statistics?.activeUsers30d ?? '-' }} |
|
|
|
</h3> |
|
|
|
<div class="h6 mb-0"> |
|
|
|
Active Users <small class="text-muted">(Last 30 days)</small> |
|
|
|
<span i18n>Active Users</span> <small class="text-muted" |
|
|
|
>(Last 30 days)</small |
|
|
|
> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="col-xs-12 col-md-4 my-2"> |
|
|
|
<div class="col-xs-12 col-md-3 my-2"> |
|
|
|
<h3 class="mb-0" [hidden]="!statistics?.gitHubContributors"> |
|
|
|
{{ statistics?.gitHubContributors ?? '-' }} |
|
|
|
</h3> |
|
|
|
<div class="h6 mb-0" i18n>Contributors on GitHub</div> |
|
|
|
</div> |
|
|
|
<div class="col-xs-12 col-md-3 my-2"> |
|
|
|
<h3 class="mb-0" [hidden]="!statistics?.gitHubStargazers"> |
|
|
|
{{ statistics?.gitHubStargazers ?? '-' }} |
|
|
|
</h3> |
|
|
|
<div class="h6 mb-0">Stars on GitHub</div> |
|
|
|
<div class="h6 mb-0" i18n>Stars on GitHub</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</mat-card-content> |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
export interface Statistics { |
|
|
|
activeUsers1d: number; |
|
|
|
activeUsers30d: number; |
|
|
|
gitHubContributors: number; |
|
|
|
gitHubStargazers: number; |
|
|
|
} |
|
|
|