consumers/current add call counters

This commit is contained in:
simonredfern 2025-12-27 22:43:27 +01:00
parent 5e06130450
commit e1173efe4c
3 changed files with 14 additions and 3 deletions

View File

@ -567,7 +567,8 @@ trait APIMethods600 {
|""",
EmptyBody,
CurrentConsumerJsonV600(
consumer_id = "123"
consumer_id = "123",
call_counters = redisCallCountersJsonV600
),
List(
UserNotLoggedIn,
@ -593,8 +594,10 @@ trait APIMethods600 {
} map {
unboxFullOrFail(_, cc.callContext, InvalidConsumerCredentials, 401)
}
currentConsumerCallCounters <- Future(RateLimitingUtil.consumerRateLimitState(consumer.consumerId.get).toList)
callCountersJson = createRedisCallCountersJson(currentConsumerCallCounters)
} yield {
(CurrentConsumerJsonV600(consumer.consumerId.get), HttpCode.`200`(callContext))
(CurrentConsumerJsonV600(consumer.consumerId.get, callCountersJson), HttpCode.`200`(callContext))
}
}
}

View File

@ -68,7 +68,8 @@ case class TokenJSON(
)
case class CurrentConsumerJsonV600(
consumer_id: String
consumer_id: String,
call_counters: RedisCallCountersJsonV600
)
case class CallLimitPostJsonV600(

View File

@ -94,6 +94,13 @@ class ConsumerTest extends V600ServerSetup {
consumerJson.consumer_id should not be empty
consumerJson.consumer_id should not be null
consumerJson.consumer_id shouldBe a[String]
consumerJson.call_counters should not be null
consumerJson.call_counters.per_second should not be null
consumerJson.call_counters.per_minute should not be null
consumerJson.call_counters.per_hour should not be null
consumerJson.call_counters.per_day should not be null
consumerJson.call_counters.per_week should not be null
consumerJson.call_counters.per_month should not be null
}
}
}