Skip to content

Commit cd03002

Browse files
authored
Merge pull request #2231 from github/nora/rename-query-history-serialization
Rename query history read and write methods
2 parents 92f50af + 3b42b67 commit cd03002

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

extensions/ql-vscode/src/legacy-query-server/run-queries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { redactableError } from "../pure/errors";
3333
export class QueryInProgress {
3434
public queryEvalInfo: QueryEvaluationInfo;
3535
/**
36-
* Note that in the {@link deserializeQueryHistory} method, we create a QueryEvaluationInfo instance
36+
* Note that in the {@link readQueryHistoryFromFile} method, we create a QueryEvaluationInfo instance
3737
* by explicitly setting the prototype in order to avoid calling this constructor.
3838
*/
3939
constructor(

extensions/ql-vscode/src/query-history/query-history-manager.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ import {
4040
variantAnalysisStatusToQueryStatus,
4141
} from "../query-status";
4242
import {
43-
deserializeQueryHistory,
44-
serializeQueryHistory,
43+
readQueryHistoryFromFile,
44+
writeQueryHistoryToFile,
4545
} from "./store/query-history-store";
4646
import { pathExists } from "fs-extra";
4747
import { CliVersionConstraint } from "../cli";
@@ -379,7 +379,7 @@ export class QueryHistoryManager extends DisposableObject {
379379
void extLogger.log(
380380
`Reading cached query history from '${this.queryMetadataStorageLocation}'.`,
381381
);
382-
const history = await deserializeQueryHistory(
382+
const history = await readQueryHistoryFromFile(
383383
this.queryMetadataStorageLocation,
384384
);
385385
this.treeDataProvider.allHistory = history;
@@ -395,7 +395,7 @@ export class QueryHistoryManager extends DisposableObject {
395395
}
396396

397397
async writeQueryHistory(): Promise<void> {
398-
await serializeQueryHistory(
398+
await writeQueryHistoryToFile(
399399
this.treeDataProvider.allHistory,
400400
this.queryMetadataStorageLocation,
401401
);

extensions/ql-vscode/src/query-history/store/query-history-store.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { QueryEvaluationInfo } from "../../run-queries-shared";
1414
import { QueryResultType } from "../../pure/legacy-messages";
1515
import { redactableError } from "../../pure/errors";
1616

17-
export async function deserializeQueryHistory(
17+
export async function readQueryHistoryFromFile(
1818
fsPath: string,
1919
): Promise<QueryHistoryInfo[]> {
2020
try {
@@ -109,7 +109,7 @@ export async function deserializeQueryHistory(
109109
* @param queries the list of queries to save.
110110
* @param fsPath the path to save the queries to.
111111
*/
112-
export async function serializeQueryHistory(
112+
export async function writeQueryHistoryToFile(
113113
queries: QueryHistoryInfo[],
114114
fsPath: string,
115115
): Promise<void> {

extensions/ql-vscode/src/query-results.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class CompletedQueryInfo implements QueryWithResults {
7070
interpretedResultsSortState: InterpretedResultsSortState | undefined;
7171

7272
/**
73-
* Note that in the {@link deserializeQueryHistory} method, we create a CompletedQueryInfo instance
73+
* Note that in the {@link readQueryHistoryFromFile} method, we create a CompletedQueryInfo instance
7474
* by explicitly setting the prototype in order to avoid calling this constructor.
7575
*/
7676
constructor(evaluation: QueryWithResults) {
@@ -224,7 +224,7 @@ export class LocalQueryInfo {
224224
public evalLogSummarySymbolsLocation: string | undefined;
225225

226226
/**
227-
* Note that in the {@link deserializeQueryHistory} method, we create a FullQueryInfo instance
227+
* Note that in the {@link readQueryHistoryFromFile} method, we create a FullQueryInfo instance
228228
* by explicitly setting the prototype in order to avoid calling this constructor.
229229
*/
230230
constructor(

extensions/ql-vscode/src/run-queries-shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function findQueryEvalLogEndSummaryFile(resultPath: string): string {
6868

6969
export class QueryEvaluationInfo {
7070
/**
71-
* Note that in the {@link deserializeQueryHistory} method, we create a QueryEvaluationInfo instance
71+
* Note that in the {@link readQueryHistoryFromFile} method, we create a QueryEvaluationInfo instance
7272
* by explicitly setting the prototype in order to avoid calling this constructor.
7373
*/
7474
constructor(

extensions/ql-vscode/test/vscode-tests/no-workspace/query-history/store/query-history-store.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
2-
deserializeQueryHistory,
3-
serializeQueryHistory,
2+
readQueryHistoryFromFile,
3+
writeQueryHistoryToFile,
44
} from "../../../../../src/query-history/store/query-history-store";
55
import { join } from "path";
66
import { writeFileSync, mkdirpSync, writeFile } from "fs-extra";
@@ -19,7 +19,7 @@ import { QueryHistoryInfo } from "../../../../../src/query-history/query-history
1919
import { createMockVariantAnalysisHistoryItem } from "../../../../factories/query-history/variant-analysis-history-item";
2020
import { nanoid } from "nanoid";
2121

22-
describe("serialize and deserialize", () => {
22+
describe("write and read", () => {
2323
let infoSuccessRaw: LocalQueryInfo;
2424
let infoSuccessInterpreted: LocalQueryInfo;
2525
let infoEarlyFailure: LocalQueryInfo;
@@ -93,20 +93,20 @@ describe("serialize and deserialize", () => {
9393
];
9494
});
9595

96-
it("should serialize and deserialize query history", async () => {
96+
it("should write and read query history", async () => {
9797
const allHistoryPath = join(tmpDir.name, "workspace-query-history.json");
9898

99-
// serialize and deserialize
100-
await serializeQueryHistory(allHistory, allHistoryPath);
101-
const allHistoryActual = await deserializeQueryHistory(allHistoryPath);
99+
// write and read
100+
await writeQueryHistoryToFile(allHistory, allHistoryPath);
101+
const allHistoryActual = await readQueryHistoryFromFile(allHistoryPath);
102102

103103
// the dispose methods will be different. Ignore them.
104104
allHistoryActual.forEach((info) => {
105105
if (info.t === "local" && info.completedQuery) {
106106
const completedQuery = info.completedQuery;
107107
(completedQuery as any).dispose = undefined;
108108

109-
// these fields should be missing on the deserialized value
109+
// these fields should be missing on the read value
110110
// but they are undefined on the original value
111111
if (!("logFileLocation" in completedQuery)) {
112112
(completedQuery as any).logFileLocation = undefined;
@@ -181,7 +181,7 @@ describe("serialize and deserialize", () => {
181181
"utf8",
182182
);
183183

184-
const actual = await deserializeQueryHistory(path);
184+
const actual = await readQueryHistoryFromFile(path);
185185
expect(actual.length).toEqual(expectedHistory.length);
186186
});
187187

@@ -196,7 +196,7 @@ describe("serialize and deserialize", () => {
196196
"utf8",
197197
);
198198

199-
const allHistoryActual = await deserializeQueryHistory(badPath);
199+
const allHistoryActual = await readQueryHistoryFromFile(badPath);
200200
// version number is invalid. Should return an empty array.
201201
expect(allHistoryActual).toEqual([]);
202202
});

0 commit comments

Comments
 (0)