Rename SortDirection data model to SortDirectionDto.
This requires us providing mapping functions for objects that use SortDirection.
This commit is contained in:
@@ -11,8 +11,18 @@ import {
|
||||
QueryEvaluationInfoDto,
|
||||
InitialQueryInfoDto,
|
||||
QueryHistoryLocalQueryDto,
|
||||
SortDirectionDto,
|
||||
InterpretedResultsSortStateDto,
|
||||
SortedResultSetInfoDto,
|
||||
RawResultsSortStateDto,
|
||||
} from "./query-history-local-query-dto";
|
||||
import { QueryHistoryDataItem } from "./query-history-data";
|
||||
import {
|
||||
InterpretedResultsSortState,
|
||||
RawResultsSortState,
|
||||
SortDirection,
|
||||
SortedResultSetInfo,
|
||||
} from "../../pure/interface-types";
|
||||
|
||||
// Maps Query History Data Models to Domain Models
|
||||
|
||||
@@ -54,6 +64,16 @@ function mapLocalQueryDataItemToDomainModel(
|
||||
function mapCompletedQueryInfoDataToDomainModel(
|
||||
completedQuery: CompletedQueryInfoDto,
|
||||
): CompletedQueryInfo {
|
||||
const sortState =
|
||||
completedQuery.interpretedResultsSortState &&
|
||||
mapSortStateToDomainModel(completedQuery.interpretedResultsSortState);
|
||||
|
||||
const sortedResults = Object.fromEntries(
|
||||
Object.entries(completedQuery.sortedResultsInfo).map(([key, value]) => {
|
||||
return [key, mapSortedResultSetInfoDtoToDomainModel(value)];
|
||||
}),
|
||||
);
|
||||
|
||||
return new CompletedQueryInfo(
|
||||
mapQueryEvaluationInfoDataToDomainModel(completedQuery.query),
|
||||
{
|
||||
@@ -67,9 +87,9 @@ function mapCompletedQueryInfoDataToDomainModel(
|
||||
completedQuery.logFileLocation,
|
||||
completedQuery.successful ?? completedQuery.sucessful,
|
||||
completedQuery.message,
|
||||
completedQuery.interpretedResultsSortState,
|
||||
sortState,
|
||||
completedQuery.resultCount,
|
||||
completedQuery.sortedResultsInfo,
|
||||
sortedResults,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -103,3 +123,43 @@ function mapQueryEvaluationInfoDataToDomainModel(
|
||||
evaluationInfo.metadata,
|
||||
);
|
||||
}
|
||||
|
||||
function mapSortDirectionToDomainModel(
|
||||
sortDirection: SortDirectionDto,
|
||||
): SortDirection {
|
||||
switch (sortDirection) {
|
||||
case SortDirectionDto.asc:
|
||||
return SortDirection.asc;
|
||||
case SortDirectionDto.desc:
|
||||
return SortDirection.desc;
|
||||
}
|
||||
}
|
||||
|
||||
function mapSortStateToDomainModel(
|
||||
sortState: InterpretedResultsSortStateDto,
|
||||
): InterpretedResultsSortState {
|
||||
return {
|
||||
sortBy: sortState.sortBy,
|
||||
sortDirection: mapSortDirectionToDomainModel(sortState.sortDirection),
|
||||
};
|
||||
}
|
||||
|
||||
function mapSortedResultSetInfoDtoToDomainModel(
|
||||
sortedResultSetInfo: SortedResultSetInfoDto,
|
||||
): SortedResultSetInfo {
|
||||
return {
|
||||
resultsPath: sortedResultSetInfo.resultsPath,
|
||||
sortState: mapRawResultsSortStateToDomainModel(
|
||||
sortedResultSetInfo.sortState,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
function mapRawResultsSortStateToDomainModel(
|
||||
sortState: RawResultsSortStateDto,
|
||||
): RawResultsSortState {
|
||||
return {
|
||||
columnIndex: sortState.columnIndex,
|
||||
sortDirection: mapSortDirectionToDomainModel(sortState.sortDirection),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,14 +1,26 @@
|
||||
import { assertNever } from "../../pure/helpers-pure";
|
||||
import { LocalQueryInfo, InitialQueryInfo } from "../../query-results";
|
||||
import {
|
||||
LocalQueryInfo,
|
||||
InitialQueryInfo,
|
||||
CompletedQueryInfo,
|
||||
} from "../../query-results";
|
||||
import { QueryEvaluationInfo } from "../../run-queries-shared";
|
||||
import { QueryHistoryInfo } from "../query-history-info";
|
||||
import {
|
||||
QueryHistoryLocalQueryDto,
|
||||
InitialQueryInfoDto,
|
||||
QueryEvaluationInfoDto,
|
||||
CompletedQueryInfoDto,
|
||||
SortedResultSetInfoDto,
|
||||
SortDirectionDto,
|
||||
} from "./query-history-local-query-dto";
|
||||
import { QueryHistoryDataItem } from "./query-history-data";
|
||||
import { VariantAnalysisDataItem } from "./variant-analysis-data-item";
|
||||
import {
|
||||
RawResultsSortState,
|
||||
SortDirection,
|
||||
SortedResultSetInfo,
|
||||
} from "../../pure/interface-types";
|
||||
|
||||
// Maps Query History Domain Models to Data Models
|
||||
|
||||
@@ -38,22 +50,65 @@ function mapLocalQueryInfoToDataModel(
|
||||
jsonEvalLogSummaryLocation: query.jsonEvalLogSummaryLocation,
|
||||
evalLogSummarySymbolsLocation: query.evalLogSummarySymbolsLocation,
|
||||
failureReason: query.failureReason,
|
||||
completedQuery: query.completedQuery && {
|
||||
query: mapQueryEvaluationInfoToDataModel(query.completedQuery.query),
|
||||
result: {
|
||||
runId: query.completedQuery.result.runId,
|
||||
queryId: query.completedQuery.result.queryId,
|
||||
resultType: query.completedQuery.result.resultType,
|
||||
evaluationTime: query.completedQuery.result.evaluationTime,
|
||||
message: query.completedQuery.result.message,
|
||||
logFileLocation: query.completedQuery.result.logFileLocation,
|
||||
},
|
||||
logFileLocation: query.completedQuery.logFileLocation,
|
||||
successful: query.completedQuery.successful,
|
||||
message: query.completedQuery.message,
|
||||
resultCount: query.completedQuery.resultCount,
|
||||
sortedResultsInfo: query.completedQuery.sortedResultsInfo,
|
||||
completedQuery:
|
||||
query.completedQuery &&
|
||||
mapCompletedQueryToDataModel(query.completedQuery),
|
||||
};
|
||||
}
|
||||
|
||||
function mapCompletedQueryToDataModel(
|
||||
query: CompletedQueryInfo,
|
||||
): CompletedQueryInfoDto {
|
||||
const sortedResults = Object.fromEntries(
|
||||
Object.entries(query.sortedResultsInfo).map(([key, value]) => {
|
||||
return [key, mapSortedResultSetInfoToDataModel(value)];
|
||||
}),
|
||||
);
|
||||
|
||||
return {
|
||||
query: mapQueryEvaluationInfoToDataModel(query.query),
|
||||
result: {
|
||||
runId: query.result.runId,
|
||||
queryId: query.result.queryId,
|
||||
resultType: query.result.resultType,
|
||||
evaluationTime: query.result.evaluationTime,
|
||||
message: query.result.message,
|
||||
logFileLocation: query.result.logFileLocation,
|
||||
},
|
||||
logFileLocation: query.logFileLocation,
|
||||
successful: query.successful,
|
||||
message: query.message,
|
||||
resultCount: query.resultCount,
|
||||
sortedResultsInfo: sortedResults,
|
||||
};
|
||||
}
|
||||
|
||||
function mapSortDirectionToDomainModel(
|
||||
sortDirection: SortDirection,
|
||||
): SortDirectionDto {
|
||||
switch (sortDirection) {
|
||||
case SortDirection.asc:
|
||||
return SortDirectionDto.asc;
|
||||
case SortDirection.desc:
|
||||
return SortDirectionDto.desc;
|
||||
}
|
||||
}
|
||||
|
||||
function mapRawResultsSortStateToDataModel(
|
||||
sortState: RawResultsSortState,
|
||||
): SortedResultSetInfoDto["sortState"] {
|
||||
return {
|
||||
columnIndex: sortState.columnIndex,
|
||||
sortDirection: mapSortDirectionToDomainModel(sortState.sortDirection),
|
||||
};
|
||||
}
|
||||
|
||||
function mapSortedResultSetInfoToDataModel(
|
||||
resultSet: SortedResultSetInfo,
|
||||
): SortedResultSetInfoDto {
|
||||
return {
|
||||
resultsPath: resultSet.resultsPath,
|
||||
sortState: mapRawResultsSortStateToDataModel(resultSet.sortState),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -48,24 +48,24 @@ export interface CompletedQueryInfoDto {
|
||||
interpretedResultsSortState?: InterpretedResultsSortStateDto;
|
||||
}
|
||||
|
||||
interface InterpretedResultsSortStateDto {
|
||||
export interface InterpretedResultsSortStateDto {
|
||||
sortBy: InterpretedResultsSortColumnDto;
|
||||
sortDirection: SortDirection;
|
||||
sortDirection: SortDirectionDto;
|
||||
}
|
||||
|
||||
type InterpretedResultsSortColumnDto = "alert-message";
|
||||
|
||||
interface SortedResultSetInfoDto {
|
||||
export interface SortedResultSetInfoDto {
|
||||
resultsPath: string;
|
||||
sortState: RawResultsSortStateDto;
|
||||
}
|
||||
|
||||
interface RawResultsSortStateDto {
|
||||
export interface RawResultsSortStateDto {
|
||||
columnIndex: number;
|
||||
sortDirection: SortDirection;
|
||||
sortDirection: SortDirectionDto;
|
||||
}
|
||||
|
||||
enum SortDirection {
|
||||
export enum SortDirectionDto {
|
||||
asc,
|
||||
desc,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user