Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions lib/clients/ValueCounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
column,
count,
type ExprNode,
type MaybeArray,
Query,
sql,
sum,
Expand All @@ -18,7 +17,6 @@ import { effect } from "@preact/signals-core";

import { ValueCountsPlot } from "../utils/ValueCountsPlot.ts";
import { assert } from "../utils/assert.ts";
import { isFlechetteTable } from "../utils/guards.ts";

interface UniqueValuesOptions {
/** The table to query. */
Expand All @@ -43,28 +41,6 @@ export class ValueCounts extends MosaicClient {
this.#table = options.table;
this.#column = options.field.name;
this.#field = options.field;

// FIXME: There is some issue with the mosaic client or the query we
// are using here. Updates to the Selection (`filterBy`) seem to be
// missed by the coordinator, and query/queryResult are not called
// by the coordinator when the filterBy is updated.
//
// Here we manually listen for the changes to filterBy and update this
// client internally. It _should_ go through the coordinator.
options.filterBy.addEventListener("value", async () => {
if (!this.#plot || !this.coordinator) {
return;
}
let filters = options.filterBy.predicate(this);
assert(
isExprNodeArray(filters),
`Filter is not expression array: ${filters}`,
);
let query = this.query(filters);
let data = await this.coordinator.query(query);
assert(isFlechetteTable(data), "Expected a flechette table.");
this.#plot.data.value = data;
});
}

override query(filter: Array<ExprNode> = []): Query {
Expand Down Expand Up @@ -130,9 +106,3 @@ export class ValueCounts extends MosaicClient {
};
}
}

function isExprNodeArray(
x: MaybeArray<string | boolean | undefined | ExprNode>,
): x is Array<ExprNode> {
return Array.isArray(x) && x.every((y) => typeof y === "object");
}