Add type signatures for aggregation logic (#623)

This is the first real step towards #502.

Factoring this out because deciding the type signatures was non-trivial,
and the work was paired with @wchargin.

Test plan: `yarn test`
This commit is contained in:
Dandelion Mané 2018-08-09 22:37:12 -07:00 committed by GitHub
parent 74e00b0bfd
commit 51acc25f12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,39 @@
// @flow
import type {NodeType, EdgeType} from "../../pluginAdapter";
import type {ScoredConnection} from "../../../core/attribution/pagerankNodeDecomposition";
// Sorted by descending `summary.score`
export type ConnectionAggregations = $ReadOnlyArray<ConnectionAggregation>;
export type AggregationSummary = {|
+size: number,
+score: number,
|};
export type NodeAggregation = {|
+nodeType: NodeType,
+summary: AggregationSummary,
+connections: $ReadOnlyArray<ScoredConnection>,
|};
export type ConnectionType =
| {|+type: "IN_EDGE", +edgeType: EdgeType|}
| {|+type: "OUT_EDGE", +edgeType: EdgeType|}
| {|+type: "SYNTHETIC_LOOP"|};
export type ConnectionAggregation = {|
+connectionType: ConnectionType,
+summary: AggregationSummary,
// Sorted by descending `summary.score`
+nodeAggregations: $ReadOnlyArray<NodeAggregation>,
|};
export function aggregateByConnectionType(
xs: $ReadOnlyArray<ScoredConnection>,
nodeTypes: $ReadOnlyArray<NodeType>,
edgeTypes: $ReadOnlyArray<EdgeType>
): ConnectionAggregations {
const _unused_stuff = [xs, edgeTypes, nodeTypes];
throw new Error("Not yet implemented");
}

View File

@ -0,0 +1,7 @@
// @flow
describe("app/credExplorer/aggregation", () => {
it("is not yet implemented", () => {
return;
});
});