Skip to content

Commit

Permalink
Replacing a few redis related string literal
Browse files Browse the repository at this point in the history
  • Loading branch information
Pozo committed Jun 15, 2024
1 parent 5bd0d0e commit 0e1715f
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.pozo.investmentfunds.api.sheets

import com.github.pozo.investmentfunds.DataFlowConstants
import com.github.pozo.investmentfunds.RateHeaders
import com.github.pozo.investmentfunds.RedisHashKey
import com.github.pozo.investmentfunds.api.redis.RedisService
import org.springframework.stereotype.Service
Expand All @@ -27,7 +28,7 @@ class SheetsService() : SheetsAPI {
isin: String,
filter: SheetsController.RatesFilter
): List<Map<String, String>> {
val attribute = filter.attribute ?: "rate"
val attribute = filter.attribute ?: RateHeaders.RATE.name.lowercase()
val startDate = filter.startDate ?: format.format(Date())
val endDate = filter.endDate ?: format.format(Date())

Expand All @@ -36,13 +37,13 @@ class SheetsService() : SheetsAPI {

RedisService.jedis.pipelined().use { pipeline ->
val results = RedisService.jedis.zrangeByScore("rate:keys#$isin", fromKey, toKey).toList()
.map { pipeline.hget(it, "date") to pipeline.hget(it, attribute) }
.map { pipeline.hget(it, RateHeaders.DATE.name.lowercase()) to pipeline.hget(it, attribute) }
pipeline.sync()

return results.stream()
.map {
mapOf<String, String>(
"date" to it.first.get(),
RateHeaders.DATE.name.lowercase() to it.first.get(),
attribute to it.second.get()
)
}
Expand Down

0 comments on commit 0e1715f

Please sign in to comment.