@@ -77,21 +77,22 @@ export async function exportRemoteQueryResults(
7777 }
7878
7979 const exportDirectory = await queryHistoryManager . getQueryHistoryItemDirectory ( queryHistoryItem ) ;
80+ const exportedResultsDirectory = path . join ( exportDirectory , 'exported-results' ) ;
8081
81- await exportRemoteQueryAnalysisResults ( ctx , exportDirectory , query , analysesResults , exportFormat ) ;
82+ await exportRemoteQueryAnalysisResults ( ctx , exportedResultsDirectory , query , analysesResults , exportFormat ) ;
8283}
8384
8485export async function exportRemoteQueryAnalysisResults (
8586 ctx : ExtensionContext ,
86- exportDirectory : string ,
87+ exportedResultsPath : string ,
8788 query : RemoteQuery ,
8889 analysesResults : AnalysisResults [ ] ,
8990 exportFormat : 'gist' | 'local' ,
9091) {
9192 const description = buildGistDescription ( query , analysesResults ) ;
9293 const markdownFiles = generateMarkdown ( query , analysesResults , exportFormat ) ;
9394
94- await exportResults ( ctx , exportDirectory , description , markdownFiles , exportFormat ) ;
95+ await exportResults ( ctx , exportedResultsPath , description , markdownFiles , exportFormat ) ;
9596}
9697
9798/**
@@ -147,20 +148,24 @@ export async function exportVariantAnalysisResults(
147148
148149 const exportDirectory = variantAnalysisManager . getVariantAnalysisStorageLocation ( variantAnalysis . id ) ;
149150
150- await exportVariantAnalysisAnalysisResults ( ctx , exportDirectory , variantAnalysis , getAnalysesResults ( ) , exportFormat ) ;
151+ // The date will be formatted like the following: 20221115T123456Z. The time is in UTC.
152+ const formattedDate = ( new Date ( ) ) . toISOString ( ) . replace ( / [ - : ] / g, '' ) . replace ( / \. \d + Z $ / , 'Z' ) ;
153+ const exportedResultsDirectory = path . join ( exportDirectory , 'exported-results' , `results_${ formattedDate } ` ) ;
154+
155+ await exportVariantAnalysisAnalysisResults ( ctx , exportedResultsDirectory , variantAnalysis , getAnalysesResults ( ) , exportFormat ) ;
151156}
152157
153158export async function exportVariantAnalysisAnalysisResults (
154159 ctx : ExtensionContext ,
155- exportDirectory : string ,
160+ exportedResultsPath : string ,
156161 variantAnalysis : VariantAnalysis ,
157162 analysesResults : AsyncIterable < [ VariantAnalysisScannedRepository , VariantAnalysisScannedRepositoryResult ] > ,
158163 exportFormat : 'gist' | 'local' ,
159164) {
160165 const description = buildVariantAnalysisGistDescription ( variantAnalysis ) ;
161166 const markdownFiles = await generateVariantAnalysisMarkdown ( variantAnalysis , analysesResults , 'gist' ) ;
162167
163- await exportResults ( ctx , exportDirectory , description , markdownFiles , exportFormat ) ;
168+ await exportResults ( ctx , exportedResultsPath , description , markdownFiles , exportFormat ) ;
164169}
165170
166171/**
@@ -201,15 +206,15 @@ async function determineExportFormat(): Promise<'gist' | 'local' | undefined> {
201206
202207export async function exportResults (
203208 ctx : ExtensionContext ,
204- exportDirectory : string ,
209+ exportedResultsPath : string ,
205210 description : string ,
206211 markdownFiles : MarkdownFile [ ] ,
207212 exportFormat : 'gist' | 'local' ,
208213) {
209214 if ( exportFormat === 'gist' ) {
210215 await exportToGist ( ctx , description , markdownFiles ) ;
211216 } else if ( exportFormat === 'local' ) {
212- await exportToLocalMarkdown ( exportDirectory , markdownFiles ) ;
217+ await exportToLocalMarkdown ( exportedResultsPath , markdownFiles ) ;
213218 }
214219}
215220
@@ -265,10 +270,9 @@ const buildVariantAnalysisGistDescription = (variantAnalysis: VariantAnalysis) =
265270 * Saves the results of an exported query to local markdown files.
266271 */
267272async function exportToLocalMarkdown (
268- exportDirectory : string ,
273+ exportedResultsPath : string ,
269274 markdownFiles : MarkdownFile [ ] ,
270275) {
271- const exportedResultsPath = path . join ( exportDirectory , 'exported-results' ) ;
272276 await fs . ensureDir ( exportedResultsPath ) ;
273277 for ( const markdownFile of markdownFiles ) {
274278 const filePath = path . join ( exportedResultsPath , `${ markdownFile . fileName } .md` ) ;
0 commit comments