mirror of
https://github.com/status-im/sourcecred.git
synced 2025-02-10 11:36:43 +00:00
Add fetchGithubGraph (#204)
fetchGithubGraph is a tiny module which is responsible for fetching GitHub contribution data, and parsing it into a graph. Test plan: The function is trivial and does not merit explicit testing.
This commit is contained in:
parent
315f66cc4c
commit
0bf4f73f86
31
src/plugins/github/fetchGithubGraph.js
Normal file
31
src/plugins/github/fetchGithubGraph.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// @flow
|
||||||
|
/*
|
||||||
|
* API to scrape data from a GitHub repo using the GitHub API. See the
|
||||||
|
* docstring of the default export for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type {NodePayload, EdgePayload} from "./types";
|
||||||
|
import type {Graph} from "../../core/graph";
|
||||||
|
import fetchGithubRepo from "./fetchGithubRepo";
|
||||||
|
import {parse} from "./parser";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scrape data from a GitHub repo, and return a SourceCred contribution graph.
|
||||||
|
*
|
||||||
|
* @param {String} repoOwner
|
||||||
|
* the GitHub username of the owner of the repository to be scraped
|
||||||
|
* @param {String} repoName
|
||||||
|
* the name of the repository to be scraped
|
||||||
|
* @param {String} token
|
||||||
|
* authentication token to be used for the GitHub API; generate a
|
||||||
|
* token at: https://github.com/settings/tokens
|
||||||
|
* @return {Promise<Graph<NodePayload, EdgePayload>}
|
||||||
|
* a promise that resolves to a GitHub contribution graph
|
||||||
|
*/
|
||||||
|
export default function fetchGithubGraph(
|
||||||
|
repoOwner: string,
|
||||||
|
repoName: string,
|
||||||
|
token: string
|
||||||
|
): Promise<Graph<NodePayload, EdgePayload>> {
|
||||||
|
return fetchGithubRepo(repoOwner, repoName, token).then((x) => parse(x));
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user