Matheus
10/09/2018, 3:19 PMprivate fun convert(recommendations: List<References>, period: Long): List<References> {
val groupedValues: Map<LocalDate, List<References>> = requestFromExternalService(period)
.asSequence()
.groupBy { it.date() }
return (period..0)
.map { groupedValues[LocalDate.now().minus(it)] ?: Reference(date= LocalDate.now().minus(it), value = DEFAULT_VALUE)}
}
Any thoughts?
EDIT: Just noticed a couple of mistakes. I had to edit the code to simplify the explanation