Fixed source integrations after refactoring

This commit is contained in:
squidfunk
2020-09-27 22:58:33 +02:00
parent c7ddada630
commit baeb4cc5bd
7 changed files with 11 additions and 14 deletions

View File

@@ -22,7 +22,7 @@
import { Repo, User } from "github-types"
import { Observable, from } from "rxjs"
import { filter, map } from "rxjs/operators"
import { map } from "rxjs/operators"
import { round } from "utilities"
@@ -48,12 +48,11 @@ export function fetchSourceFactsFromGitHub(
: `https://api.github.com/users/${user}`
return from(fetch(url).then(res => res.json()))
.pipe(
filter(({ status }) => status === 200),
map(({ response }) => {
map(data => {
/* GitHub repository */
if (typeof repo !== "undefined") {
const { stargazers_count, forks_count }: Repo = response
const { stargazers_count, forks_count }: Repo = data
return [
`${round(stargazers_count || 0)} Stars`,
`${round(forks_count || 0)} Forks`
@@ -61,7 +60,7 @@ export function fetchSourceFactsFromGitHub(
/* GitHub user/organization */
} else {
const { public_repos }: User = response
const { public_repos }: User = data
return [
`${round(public_repos || 0)} Repositories`
]

View File

@@ -22,7 +22,7 @@
import { ProjectSchema } from "gitlab"
import { Observable, from } from "rxjs"
import { filter, map } from "rxjs/operators"
import { map } from "rxjs/operators"
import { round } from "utilities"
@@ -46,8 +46,6 @@ export function fetchSourceFactsFromGitLab(
const url = `https://${base}/api/v4/projects/${encodeURIComponent(project)}`
return from(fetch(url).then(res => res.json()))
.pipe(
filter(({ status }) => status === 200),
map(({ response }) => response),
map(({ star_count, forks_count }: ProjectSchema) => ([
`${round(star_count)} Stars`,
`${round(forks_count)} Forks`