Skip to content

Commit 5a6af2a

Browse files
lmarinibodom0015
andauthored
Use Scala's built-in map and distinct to count the number of unique extractor job entries
This should not affect the calculation of the runtimes, as the lastweeksubmitted and lastmonthsubmitted are not used in this calculation loop. Co-authored-by: Mike Lambert <[email protected]>
1 parent 444f116 commit 5a6af2a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

app/controllers/Extractors.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,12 @@ class Extractors @Inject() (extractions: ExtractionService,
159159
}
160160
Logger.debug("average: " + average)
161161
// get at the number of ``SUBMITTED'' submission in last week.
162-
val lastweeksubmitted = extractions.findByExtractorIDBefore(extractorName, "SUBMITTED", last7daydate, 0)
163-
Logger.debug("lastweek submitted: " + lastweeksubmitted.size)
162+
val lastweekevents = extractions.findByExtractorIDBefore(extractorName, "SUBMITTED", last7daydate, 0)
163+
val lastweeksubmitted = lastweekevents.map(evt => evt.job_id).distinct.length
164+
Logger.debug("lastweek submitted: " + lastweeksubmitted)
164165
// get at the number of ``SUBMITTED'' submission in last month.
165-
val lastmonthsubmitted = extractions.findByExtractorIDBefore(extractorName, "SUBMITTED", lastmonthdate, 0)
166+
val lastmonthevents = extractions.findByExtractorIDBefore(extractorName, "SUBMITTED", lastmonthdate, 0)
167+
val lastmonthsubmitted = lastmonthevents.map(evt => evt.job_id).distinct.length
166168

167169
// calculate the last 10 execution average time in the time range of last month between ``SUBMITTED'' and ``DONE''.
168170
// get at most 10 ``DONE'' submission from last month.
@@ -190,7 +192,7 @@ class Extractors @Inject() (extractions: ExtractionService,
190192

191193
val targetExtractor = extractorService.listExtractorsInfo(List.empty).find(p => p.name == extractorName)
192194
targetExtractor match {
193-
case Some(extractor) => Ok(views.html.extractorMetrics(extractorName, average.toString, lastTenAverage.toString, lastweeksubmitted.size, lastmonthsubmitted.size))
195+
case Some(extractor) => Ok(views.html.extractorMetrics(extractorName, average.toString, lastTenAverage.toString, lastweeksubmitted, lastmonthsubmitted))
194196
case None => InternalServerError("Extractor Info not found: " + extractorName)
195197
}
196198
}
@@ -248,4 +250,4 @@ class Extractors @Inject() (extractions: ExtractionService,
248250
case None => InternalServerError("Dataset not found")
249251
}
250252
}
251-
}
253+
}

0 commit comments

Comments
 (0)