mirror of
https://github.com/status-im/sourcecred.git
synced 2025-02-27 11:40:26 +00:00
add loadWeightedGraph
modules for plugins (#1602)
This commit adds `loadWeightedGraph` modules for both the GitHub and Discourse plugins. They will replacing existing (and inconsistently named) modules which load regular graphs. In addition to loading the underlying graph, they set weights according to the plugins' default type-level weights. The soon-to-be-replaced modules have been marked deprecated. Another small and vital step towards #1557. Test plan: The functions that these functions replace are not tested, because they are IO-heavy composition methods which are painful to test themselves, and directly depend on well-tested behavior. For the same reason, no unit tests have been added. Given the nature of the methods in question, it's unlikely that they'll be sublty broken.
This commit is contained in:
parent
4407c4f9fc
commit
1dd7e7a3c3
@ -1,5 +1,13 @@
|
||||
// @flow
|
||||
|
||||
// This module is deprecated, and is being replaced by
|
||||
// discourse/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 Database from "better-sqlite3";
|
||||
import base64url from "base64url";
|
||||
import {Fetcher} from "./fetch";
|
||||
|
24
src/plugins/discourse/loadWeightedGraph.js
Normal file
24
src/plugins/discourse/loadWeightedGraph.js
Normal file
@ -0,0 +1,24 @@
|
||||
// @flow
|
||||
//
|
||||
// This module is the entry point for clients of the Discourse plugin that
|
||||
// want to load a completed WeightedGraph containing Discourse data.
|
||||
//
|
||||
// This module is untested, because it is an IO-heavy composition of pieces of
|
||||
// functionality which are individually quite well tested.
|
||||
|
||||
import {loadDiscourse, type Options} from "./loadDiscourse";
|
||||
import {TaskReporter} from "../../util/taskReporter";
|
||||
import {weightsForDeclaration} from "../../analysis/pluginDeclaration";
|
||||
import {type WeightedGraph} from "../../core/weightedGraph";
|
||||
import {declaration} from "./declaration";
|
||||
|
||||
export type {Options} from "./loadDiscourse";
|
||||
|
||||
export async function loadWeightedGraph(
|
||||
options: Options,
|
||||
reporter: TaskReporter
|
||||
): Promise<WeightedGraph> {
|
||||
const graph = await loadDiscourse(options, reporter);
|
||||
const weights = weightsForDeclaration(declaration);
|
||||
return {graph, weights};
|
||||
}
|
@ -1,5 +1,13 @@
|
||||
// @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 fetchGithubRepo from "./fetchGithubRepo";
|
||||
|
24
src/plugins/github/loadWeightedGraph.js
Normal file
24
src/plugins/github/loadWeightedGraph.js
Normal file
@ -0,0 +1,24 @@
|
||||
// @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…
x
Reference in New Issue
Block a user