public void ProcessOutputMultipleFile <T>(string filePrefix, Dictionary <DateTime, Dictionary <string, T> > dict) where T : IOutputJson { var listOfLists = dataConverter.ConvertDictToOrderedListPerDay <T>(dict); logger.LogToConsole(listOfLists.Count + " files to output"); foreach (var list in listOfLists) { ProcessOutputSingleFile(filePrefix + "_" + list.Key.ToString("yyyy-MM-dd") + ".json", list.Value.Values); } }
public void Process(SonarGenericMetricsCosmosDbCommandLineArgs a, Dictionary <DateTime, Dictionary <string, DailyCodeChurn> > data) { var documentsPerDay = dataConverter.ConvertDictToOrderedListPerDay(data); var outputJson = new SonarMeasuresJson(); foreach (var document in documentsPerDay) { this.logger.LogToConsole($"Processing document with date: {document.Key}"); var codeChurnList = document.Value.Values; ProcessDailyCodeChurnList(codeChurnList, outputJson); } this.jsonExporter.Export(outputJson, a.OutputFile); }
public void ProcessOutput <T>(OutputType outputType, string outputFile, Dictionary <DateTime, Dictionary <string, T> > dict) where T : IOutputJson { dict = dict.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); logger.LogToConsole($"Started inserting documents for ('{projectName}') project of '({DocumentTypeHelper.GetDocumentType<T>()}') type."); var listOfFilesPerDay = dataConverter.ConvertDictToOrderedListPerDay(dict); var cosmosDocumentsToInsert = (from x in listOfFilesPerDay from valueValue in x.Value.Values select ConvertOutputJsonToCosmosDataDocument(valueValue, DocumentTypeHelper.GetDocumentType <T>(), x.Key)).ToList(); if (cosmosDocumentsToInsert.Count >= batchSize) { logger.LogToConsole("Inserting documents with batches."); BatchDeleteDocuments <T>(dict.First().Key, dict.Last().Key); BatchInsertDocuments(cosmosDocumentsToInsert); } else { DeleteDocuments(cosmosDocumentsToInsert); InsertDocuments(cosmosDocumentsToInsert); } logger.LogToConsole($"Finished inserting documents to cosmos for ('{projectName}') project of '({DocumentTypeHelper.GetDocumentType<T>()}') type."); }