Some restructuring around variant analysis mapper functions (#3412)
This commit is contained in:
Родитель
359ee76d52
Коммит
b884cff14d
|
@ -45,7 +45,7 @@ import type {
|
|||
} from "./variant-analysis-results-manager";
|
||||
import { getQueryName, prepareRemoteQueryRun } from "./run-remote-query";
|
||||
import {
|
||||
mapVariantAnalysis,
|
||||
mapVariantAnalysisFromSubmission,
|
||||
mapVariantAnalysisRepositoryTask,
|
||||
} from "./variant-analysis-mapper";
|
||||
import PQueue from "p-queue";
|
||||
|
@ -387,7 +387,7 @@ export class VariantAnalysisManager
|
|||
throw e;
|
||||
}
|
||||
|
||||
const mappedVariantAnalysis = mapVariantAnalysis(
|
||||
const mappedVariantAnalysis = mapVariantAnalysisFromSubmission(
|
||||
variantAnalysisSubmission,
|
||||
variantAnalysisResponse,
|
||||
);
|
||||
|
|
|
@ -23,11 +23,11 @@ import {
|
|||
VariantAnalysisRepoStatus,
|
||||
} from "./shared/variant-analysis";
|
||||
|
||||
export function mapVariantAnalysis(
|
||||
export function mapVariantAnalysisFromSubmission(
|
||||
submission: VariantAnalysisSubmission,
|
||||
response: ApiVariantAnalysis,
|
||||
apiVariantAnalysis: ApiVariantAnalysis,
|
||||
): VariantAnalysis {
|
||||
return mapUpdatedVariantAnalysis(
|
||||
return mapVariantAnalysis(
|
||||
{
|
||||
language: submission.language,
|
||||
query: {
|
||||
|
@ -41,12 +41,23 @@ export function mapVariantAnalysis(
|
|||
executionStartTime: submission.startTime,
|
||||
},
|
||||
undefined,
|
||||
response,
|
||||
apiVariantAnalysis,
|
||||
);
|
||||
}
|
||||
|
||||
export function mapUpdatedVariantAnalysis(
|
||||
previousVariantAnalysis: Pick<
|
||||
currentVariantAnalysis: VariantAnalysis,
|
||||
apiVariantAnalysis: ApiVariantAnalysis,
|
||||
): VariantAnalysis {
|
||||
return mapVariantAnalysis(
|
||||
currentVariantAnalysis,
|
||||
currentVariantAnalysis.status,
|
||||
apiVariantAnalysis,
|
||||
);
|
||||
}
|
||||
|
||||
function mapVariantAnalysis(
|
||||
currentVariantAnalysis: Pick<
|
||||
VariantAnalysis,
|
||||
"language" | "query" | "queries" | "databases" | "executionStartTime"
|
||||
>,
|
||||
|
@ -82,11 +93,11 @@ export function mapUpdatedVariantAnalysis(
|
|||
fullName: response.controller_repo.full_name,
|
||||
private: response.controller_repo.private,
|
||||
},
|
||||
language: previousVariantAnalysis.language,
|
||||
query: previousVariantAnalysis.query,
|
||||
queries: previousVariantAnalysis.queries,
|
||||
databases: previousVariantAnalysis.databases,
|
||||
executionStartTime: previousVariantAnalysis.executionStartTime,
|
||||
language: currentVariantAnalysis.language,
|
||||
query: currentVariantAnalysis.query,
|
||||
queries: currentVariantAnalysis.queries,
|
||||
databases: currentVariantAnalysis.databases,
|
||||
executionStartTime: currentVariantAnalysis.executionStartTime,
|
||||
createdAt: response.created_at,
|
||||
updatedAt: response.updated_at,
|
||||
status,
|
||||
|
|
|
@ -128,8 +128,10 @@ export class VariantAnalysisMonitor extends DisposableObject {
|
|||
// may not be aware of it yet.
|
||||
const currentStatus = this.getVariantAnalysisStatus(variantAnalysis.id);
|
||||
variantAnalysis = mapUpdatedVariantAnalysis(
|
||||
variantAnalysis,
|
||||
currentStatus,
|
||||
{
|
||||
...variantAnalysis,
|
||||
status: currentStatus,
|
||||
},
|
||||
variantAnalysisSummary,
|
||||
);
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import type { VariantAnalysisScannedRepository } from "../../../src/variant-anal
|
|||
import { VariantAnalysisRepoStatus } from "../../../src/variant-analysis/shared/variant-analysis";
|
||||
import {
|
||||
mapScannedRepository,
|
||||
mapVariantAnalysis,
|
||||
mapVariantAnalysisFromSubmission,
|
||||
mapVariantAnalysisRepositoryTask,
|
||||
} from "../../../src/variant-analysis/variant-analysis-mapper";
|
||||
import {
|
||||
|
@ -17,7 +17,7 @@ import { createMockSubmission } from "../../factories/variant-analysis/shared/va
|
|||
import { createMockVariantAnalysisRepoTask } from "../../factories/variant-analysis/gh-api/variant-analysis-repo-task";
|
||||
import { QueryLanguage } from "../../../src/common/query-language";
|
||||
|
||||
describe(mapVariantAnalysis.name, () => {
|
||||
describe(mapVariantAnalysisFromSubmission.name, () => {
|
||||
const scannedRepos = createMockScannedRepos();
|
||||
const skippedRepos = createMockSkippedRepos();
|
||||
const mockApiResponse = createMockApiResponse(
|
||||
|
@ -28,7 +28,10 @@ describe(mapVariantAnalysis.name, () => {
|
|||
const mockSubmission = createMockSubmission();
|
||||
|
||||
it("should map an API response and return a variant analysis", () => {
|
||||
const result = mapVariantAnalysis(mockSubmission, mockApiResponse);
|
||||
const result = mapVariantAnalysisFromSubmission(
|
||||
mockSubmission,
|
||||
mockApiResponse,
|
||||
);
|
||||
|
||||
const {
|
||||
access_mismatch_repos,
|
||||
|
|
|
@ -131,11 +131,7 @@ describe("Variant Analysis Monitor", () => {
|
|||
index + 1,
|
||||
"codeQL.autoDownloadVariantAnalysisResult",
|
||||
mapScannedRepository(succeededRepo),
|
||||
mapUpdatedVariantAnalysis(
|
||||
variantAnalysis,
|
||||
variantAnalysis.status,
|
||||
mockApiResponse,
|
||||
),
|
||||
mapUpdatedVariantAnalysis(variantAnalysis, mockApiResponse),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче