1- import {
2- LocalQueryInfo ,
3- CompletedQueryInfo ,
4- InitialQueryInfo ,
5- } from "../../query-results" ;
6- import { QueryEvaluationInfo } from "../../run-queries-shared" ;
71import { QueryHistoryInfo } from "../query-history-info" ;
8- import {
9- CompletedQueryInfoDto ,
10- QueryEvaluationInfoDto ,
11- InitialQueryInfoDto ,
12- QueryHistoryLocalQueryDto ,
13- SortDirectionDto ,
14- InterpretedResultsSortStateDto ,
15- SortedResultSetInfoDto ,
16- RawResultsSortStateDto ,
17- } from "./query-history-local-query-dto" ;
182import { QueryHistoryItemDto } from "./query-history-dto" ;
19- import {
20- InterpretedResultsSortState ,
21- RawResultsSortState ,
22- SortDirection ,
23- SortedResultSetInfo ,
24- } from "../../pure/interface-types" ;
253import { mapQueryHistoryVariantAnalysisToDomainModel } from "./query-history-variant-analysis-dto-mapper" ;
4+ import { mapLocalQueryItemToDomainModel } from "./query-history-local-query-dto-mapper" ;
265
276export function mapQueryHistoryToDomainModel (
287 queries : QueryHistoryItemDto [ ] ,
@@ -41,122 +20,3 @@ export function mapQueryHistoryToDomainModel(
4120 ) ;
4221 } ) ;
4322}
44-
45- function mapLocalQueryItemToDomainModel (
46- localQuery : QueryHistoryLocalQueryDto ,
47- ) : LocalQueryInfo {
48- return new LocalQueryInfo (
49- mapInitialQueryInfoToDomainModel ( localQuery . initialInfo ) ,
50- undefined ,
51- localQuery . failureReason ,
52- localQuery . completedQuery &&
53- mapCompletedQueryInfoToDomainModel ( localQuery . completedQuery ) ,
54- localQuery . evalLogLocation ,
55- localQuery . evalLogSummaryLocation ,
56- localQuery . jsonEvalLogSummaryLocation ,
57- localQuery . evalLogSummarySymbolsLocation ,
58- ) ;
59- }
60-
61- function mapCompletedQueryInfoToDomainModel (
62- completedQuery : CompletedQueryInfoDto ,
63- ) : CompletedQueryInfo {
64- const sortState =
65- completedQuery . interpretedResultsSortState &&
66- mapSortStateToDomainModel ( completedQuery . interpretedResultsSortState ) ;
67-
68- const sortedResults = Object . fromEntries (
69- Object . entries ( completedQuery . sortedResultsInfo ) . map ( ( [ key , value ] ) => {
70- return [ key , mapSortedResultSetInfoToDomainModel ( value ) ] ;
71- } ) ,
72- ) ;
73-
74- return new CompletedQueryInfo (
75- mapQueryEvaluationInfoToDomainModel ( completedQuery . query ) ,
76- {
77- runId : completedQuery . result . runId ,
78- queryId : completedQuery . result . queryId ,
79- resultType : completedQuery . result . resultType ,
80- evaluationTime : completedQuery . result . evaluationTime ,
81- message : completedQuery . result . message ,
82- logFileLocation : completedQuery . result . logFileLocation ,
83- } ,
84- completedQuery . logFileLocation ,
85- completedQuery . successful ?? completedQuery . sucessful ,
86- completedQuery . message ,
87- sortState ,
88- completedQuery . resultCount ,
89- sortedResults ,
90- ) ;
91- }
92-
93- function mapInitialQueryInfoToDomainModel (
94- initialInfo : InitialQueryInfoDto ,
95- ) : InitialQueryInfo {
96- return {
97- userSpecifiedLabel : initialInfo . userSpecifiedLabel ,
98- queryText : initialInfo . queryText ,
99- isQuickQuery : initialInfo . isQuickQuery ,
100- isQuickEval : initialInfo . isQuickEval ,
101- quickEvalPosition : initialInfo . quickEvalPosition ,
102- queryPath : initialInfo . queryPath ,
103- databaseInfo : {
104- databaseUri : initialInfo . databaseInfo . databaseUri ,
105- name : initialInfo . databaseInfo . name ,
106- } ,
107- start : new Date ( initialInfo . start ) ,
108- id : initialInfo . id ,
109- } ;
110- }
111-
112- function mapQueryEvaluationInfoToDomainModel (
113- evaluationInfo : QueryEvaluationInfoDto ,
114- ) : QueryEvaluationInfo {
115- return new QueryEvaluationInfo (
116- evaluationInfo . querySaveDir ,
117- evaluationInfo . dbItemPath ,
118- evaluationInfo . databaseHasMetadataFile ,
119- evaluationInfo . quickEvalPosition ,
120- evaluationInfo . metadata ,
121- ) ;
122- }
123-
124- function mapSortDirectionToDomainModel (
125- sortDirection : SortDirectionDto ,
126- ) : SortDirection {
127- switch ( sortDirection ) {
128- case SortDirectionDto . asc :
129- return SortDirection . asc ;
130- case SortDirectionDto . desc :
131- return SortDirection . desc ;
132- }
133- }
134-
135- function mapSortStateToDomainModel (
136- sortState : InterpretedResultsSortStateDto ,
137- ) : InterpretedResultsSortState {
138- return {
139- sortBy : sortState . sortBy ,
140- sortDirection : mapSortDirectionToDomainModel ( sortState . sortDirection ) ,
141- } ;
142- }
143-
144- function mapSortedResultSetInfoToDomainModel (
145- sortedResultSetInfo : SortedResultSetInfoDto ,
146- ) : SortedResultSetInfo {
147- return {
148- resultsPath : sortedResultSetInfo . resultsPath ,
149- sortState : mapRawResultsSortStateToDomainModel (
150- sortedResultSetInfo . sortState ,
151- ) ,
152- } ;
153- }
154-
155- function mapRawResultsSortStateToDomainModel (
156- sortState : RawResultsSortStateDto ,
157- ) : RawResultsSortState {
158- return {
159- columnIndex : sortState . columnIndex ,
160- sortDirection : mapSortDirectionToDomainModel ( sortState . sortDirection ) ,
161- } ;
162- }
0 commit comments