Github: remove unused loaders (#1635)
This commit is contained in:
parent
3c971ebaef
commit
9cf412c437
|
@ -1,66 +0,0 @@
|
|||
// @flow
|
||||
|
||||
// This module is deprecated, and is being replaced by
|
||||
// github/loadWeightedGraph. Over the course of finishing #1557,
|
||||
// @decentralion will remove this module and merge its implementation into
|
||||
// loadWeightedGraph.
|
||||
//
|
||||
// This module is untested, because it is an IO-heavy composition of pieces of
|
||||
// functionality which are individually quite well tested.
|
||||
|
||||
import {TaskReporter} from "../../util/taskReporter";
|
||||
import {createGraph} from "./createGraph";
|
||||
import {
|
||||
default as fetchGithubRepo,
|
||||
fetchGithubRepoFromCache,
|
||||
} from "./fetchGithubRepo";
|
||||
import {RelationalView} from "./relationalView";
|
||||
import {type RepoId, repoIdToString} from "./repoId";
|
||||
import {Graph} from "../../core/graph";
|
||||
import {type GithubToken} from "./token";
|
||||
import {type CacheProvider} from "../../backend/cache";
|
||||
|
||||
export type Options = {|
|
||||
+repoIds: $ReadOnlyArray<RepoId>,
|
||||
+token: GithubToken,
|
||||
+cache: CacheProvider,
|
||||
|};
|
||||
|
||||
/**
|
||||
* Loads several GitHub repositories, combining them into a single graph.
|
||||
*/
|
||||
export async function loadGraph(
|
||||
options: Options,
|
||||
taskReporter: TaskReporter
|
||||
): Promise<Graph> {
|
||||
// We intentionally fetch repositories sequentially rather than in
|
||||
// parallel, because GitHub asks that we not make concurrent
|
||||
// requests. From <https://archive.is/LlkQp#88%>:
|
||||
//
|
||||
// > Make requests for a single user or client ID serially. Do not make
|
||||
// > make requests for a single user or client ID concurrently.
|
||||
const repositories = [];
|
||||
for (const repoId of options.repoIds) {
|
||||
const taskId = `github/${repoIdToString(repoId)}`;
|
||||
taskReporter.start(taskId);
|
||||
repositories.push(
|
||||
await fetchGithubRepo(repoId, {
|
||||
token: options.token,
|
||||
cache: options.cache,
|
||||
}).then((_) =>
|
||||
fetchGithubRepoFromCache(repoId, {
|
||||
token: options.token,
|
||||
cache: options.cache,
|
||||
})
|
||||
)
|
||||
);
|
||||
taskReporter.finish(taskId);
|
||||
}
|
||||
return Graph.merge(
|
||||
repositories.map((r) => {
|
||||
const rv = new RelationalView();
|
||||
rv.addRepository(r);
|
||||
return createGraph(rv);
|
||||
})
|
||||
);
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
// @flow
|
||||
//
|
||||
// This module is the entry point for clients of the GitHub plugin that
|
||||
// want to load a completed WeightedGraph containing GitHub data.
|
||||
//
|
||||
// This module is untested, because it is an IO-heavy composition of pieces of
|
||||
// functionality which are individually quite well tested.
|
||||
|
||||
import {loadGraph, type Options} from "./loadGraph";
|
||||
import {TaskReporter} from "../../util/taskReporter";
|
||||
import {weightsForDeclaration} from "../../analysis/pluginDeclaration";
|
||||
import {type WeightedGraph} from "../../core/weightedGraph";
|
||||
import {declaration} from "./declaration";
|
||||
|
||||
export type {Options} from "./loadGraph";
|
||||
|
||||
export async function loadWeightedGraph(
|
||||
options: Options,
|
||||
reporter: TaskReporter
|
||||
): Promise<WeightedGraph> {
|
||||
const graph = await loadGraph(options, reporter);
|
||||
const weights = weightsForDeclaration(declaration);
|
||||
return {graph, weights};
|
||||
}
|
Loading…
Reference in New Issue