@VisibleForTesting internal fun getHistoryHighlights( highlights: List<HistoryHighlight>, metadata: List<HistoryMetadata>, ): List<HistoryHighlightInternal> { val highlightsUrls = highlights.map { it.url } val highlightsLastUpdatedTime = metadata .filter { highlightsUrls.contains(it.key.url) } .groupBy { it.key.url } .map { (url, data) -> url to data.maxByOrNull { it.updatedAt }!! } return highlights.map { HistoryHighlightInternal( historyHighlight = it, lastAccessedTime = highlightsLastUpdatedTime .firstOrNull { (url, _) -> url == it.url }?.second?.updatedAt ?: 0, ) } }
Perform an in-memory mapping of a history highlight to metadata records to compute its last access time.