From 127cf5207a7065e4612eebde6ff377142ad5a9ba Mon Sep 17 00:00:00 2001 From: okanmercan Date: Thu, 20 Jul 2023 14:41:34 +0300 Subject: [PATCH] :recycle: refactor(ExecutionService): Rename jobErrorLogs as mappingErrorLogs to prevent confusion. --- .../tofhir/server/service/ExecutionService.scala | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tofhir-server/src/main/scala/io/tofhir/server/service/ExecutionService.scala b/tofhir-server/src/main/scala/io/tofhir/server/service/ExecutionService.scala index 63796f2e..21ea9532 100644 --- a/tofhir-server/src/main/scala/io/tofhir/server/service/ExecutionService.scala +++ b/tofhir-server/src/main/scala/io/tofhir/server/service/ExecutionService.scala @@ -147,27 +147,27 @@ class ExecutionService(jobRepository: IJobRepository, mappingRepository: IMappin Seq.empty } else { - // Get job run logs for the given execution. ProjectId field is not null for selecting jobRunsLogs, filter out job error logs. + // Get job run logs for the given execution. ProjectId field is not null for selecting jobRunsLogs, filter out mapping error logs. val jobRunLogs = dataFrame.filter(s"executionId = '$executionId' and projectId is not null") // Handle the case where the job has not been run yet, which makes the data frame empty if (jobRunLogs.isEmpty) { Seq.empty } else { - // Get error logs for the given execution and select needed columns. ProjectId field is null for selecting job error logs, filter out jobRunsLogs. - val jobErrorLogs = dataFrame.filter(s"executionId = '$executionId' and projectId is null").select(List("errorCode", "errorDesc", "message", "mappingUrl").map(col):_*) + // Get error logs for the given execution and select needed columns. ProjectId field is null for selecting mapping error logs, filter out jobRunsLogs. + val mappingErrorLogs = dataFrame.filter(s"executionId = '$executionId' and projectId is null").select(List("errorCode", "errorDesc", "message", "mappingUrl").map(col):_*) - // Group job error logs by mapping url - val jobErrorLogsGroupedByMappingUrl = jobErrorLogs.groupByKey(row => row.get(row.fieldIndex("mappingUrl")).toString)(Encoders.STRING) + // Group mapping error logs by mapping url + val jobErrorLogsGroupedByMappingUrl = mappingErrorLogs.groupByKey(row => row.get(row.fieldIndex("mappingUrl")).toString)(Encoders.STRING) - // Collect job run logs for matching with mappingUrl field of job error logs + // Collect job run logs for matching with mappingUrl field of mapping error logs var jobRunLogsData = jobRunLogs.collect() - // Add error details to job run logs if any error occurred while executing the job. + // Add mapping error details to job run logs if any error occurred while executing the job. val jobRunLogsWithErrorDetails = jobErrorLogsGroupedByMappingUrl.mapGroups((key, values) => { // Find the related job run log to given mapping url val jobRunLog = jobRunLogsData.filter(row => row.getAs[String]("mappingUrl") == key) - // Append error logs to the related job run log + // Append mapping error logs to the related job run log Row.fromSeq(Row.unapplySeq(jobRunLog.head).get :+ values.toSeq) })( // Define a new schema for the resulting rows and create an encoder for it. We will add a "error_logs" column to job run logs that contains related error logs.