Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Invalidate cached Total Loan Balance metrics after aggregation logic change.
-- Cached entries will be rebuilt on next request with the updated go-pulse-service query.
DELETE FROM pulse_cache

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This deletes the entire history of these metrics. Are we sure that's what we want to do? If so, are we able to backfill and rebuild the history?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it's definitely :badvibes: I should've caught.

But how should we handle the old data? Just leave it be and show a drop in TBL? Backfill using a different approach?

WHERE type IN (
'LOAN_LEDGER_TOTAL_BALANCE_METRIC',
'LOAN_LEDGER_TOTAL_COUNT_METRIC'
);
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ data class PulseMetric(
val quoteAmount: BigDecimal?,
val trend: MetricTrend? = null,
val progress: MetricProgress? = null,
val series: MetricSeries? = null
val series: MetricSeries? = null,
val asOfDate: String? = null,
val dataStartDate: String? = null
) {
companion object {
fun build(
Expand All @@ -22,15 +24,19 @@ data class PulseMetric(
quote: String? = null,
quoteAmount: BigDecimal? = null,
series: MetricSeries? = null,
progress: MetricProgress? = null
progress: MetricProgress? = null,
asOfDate: String? = null,
dataStartDate: String? = null
) = PulseMetric(
id = UUID.randomUUID(),
base = base,
amount = amount,
quote = quote,
quoteAmount = quoteAmount,
series = series,
progress = progress
progress = progress,
asOfDate = asOfDate,
dataStartDate = dataStartDate
)

fun build(
Expand All @@ -40,7 +46,9 @@ data class PulseMetric(
quote: String? = null,
quoteAmount: BigDecimal? = null,
series: MetricSeries? = null,
progress: MetricProgress? = null
progress: MetricProgress? = null,
asOfDate: String? = null,
dataStartDate: String? = null
) =
PulseMetric(
id = UUID.randomUUID(),
Expand All @@ -57,7 +65,9 @@ data class PulseMetric(
period = MetricTrendPeriod.DAY
),
series = series,
progress = progress
progress = progress,
asOfDate = asOfDate,
dataStartDate = dataStartDate
)

// create a function called build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,9 @@ class PulseMetricService(
}.body<JsonNode>().let {
PulseMetric.build(
base = USD_UPPER,
amount = it["TotalBalance"].asText().toBigDecimal()
amount = it["TotalBalance"].asText().toBigDecimal(),
asOfDate = it["AsOfDate"]?.asText(),
dataStartDate = it["DataStartDate"]?.asText()
)
}
}
Expand All @@ -1097,7 +1099,9 @@ class PulseMetricService(
}.body<JsonNode>().let {
PulseMetric.build(
base = count,
amount = it["TotalCount"].asText().toBigDecimal()
amount = it["TotalCount"].asText().toBigDecimal(),
asOfDate = it["AsOfDate"]?.asText(),
dataStartDate = it["DataStartDate"]?.asText()
)
}
}
Expand Down
Loading