mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 13:26:51 +00:00
OBPv510/refactor new endpoint getAggregateMetrics-use isNewVersion Boolean
This commit is contained in:
parent
59b556a19e
commit
4dfa7134a5
@ -2164,7 +2164,7 @@ trait APIMethods300 {
|
||||
_ <- NewStyle.function.hasEntitlement("", u.userId, ApiRole.canReadAggregateMetrics, callContext)
|
||||
httpParams <- NewStyle.function.extractHttpParamsFromUrl(cc.url)
|
||||
(obpQueryParams, callContext) <- createQueriesByHttpParamsFuture(httpParams, callContext)
|
||||
aggregateMetrics <- APIMetrics.apiMetrics.vend.getAllAggregateMetricsFuture(obpQueryParams, ApiVersion.v3_0_0) map {
|
||||
aggregateMetrics <- APIMetrics.apiMetrics.vend.getAllAggregateMetricsFuture(obpQueryParams, false) map {
|
||||
x => unboxFullOrFail(x, callContext, GetAggregateMetricsError)
|
||||
}
|
||||
} yield {
|
||||
|
||||
@ -430,7 +430,7 @@ trait APIMethods510 {
|
||||
_ <- NewStyle.function.hasEntitlement("", u.userId, ApiRole.canReadAggregateMetrics, callContext)
|
||||
httpParams <- NewStyle.function.extractHttpParamsFromUrl(cc.url)
|
||||
(obpQueryParams, callContext) <- createQueriesByHttpParamsFuture(httpParams, callContext)
|
||||
aggregateMetrics <- APIMetrics.apiMetrics.vend.getAllAggregateMetricsFuture(obpQueryParams,OBPAPI5_1_0.version) map {
|
||||
aggregateMetrics <- APIMetrics.apiMetrics.vend.getAllAggregateMetricsFuture(obpQueryParams,true) map {
|
||||
x => unboxFullOrFail(x, callContext, GetAggregateMetricsError)
|
||||
}
|
||||
} yield {
|
||||
|
||||
@ -84,8 +84,14 @@ trait APIMetrics {
|
||||
// def getAllGroupedByUserId() : Map[String, List[APIMetric]]
|
||||
|
||||
def getAllMetrics(queryParams: List[OBPQueryParam]): List[APIMetric]
|
||||
|
||||
def getAllAggregateMetricsFuture(queryParams: List[OBPQueryParam], apiVersion: ApiVersion): Future[Box[List[AggregateMetrics]]]
|
||||
|
||||
/**
|
||||
*
|
||||
* @param queryParams
|
||||
* @param isNewVersion from V510, we change the queryParams, use includeXxx instead of excludeXxxx, so add this flag
|
||||
* @return
|
||||
*/
|
||||
def getAllAggregateMetricsFuture(queryParams: List[OBPQueryParam], isNewVersion: Boolean): Future[Box[List[AggregateMetrics]]]
|
||||
|
||||
def getTopApisFuture(queryParams: List[OBPQueryParam]): Future[Box[List[TopApi]]]
|
||||
|
||||
@ -102,7 +108,7 @@ class RemotedataMetricsCaseClasses {
|
||||
// case class getAllGroupedByDay()
|
||||
// case class getAllGroupedByUserId()
|
||||
case class getAllMetrics(queryParams: List[OBPQueryParam])
|
||||
case class getAllAggregateMetricsFuture(queryParams: List[OBPQueryParam], apiVersion: ApiVersion)
|
||||
case class getAllAggregateMetricsFuture(queryParams: List[OBPQueryParam], isNewVersion: Boolean)
|
||||
case class getTopApisFuture(queryParams: List[OBPQueryParam])
|
||||
case class getTopConsumersFuture(queryParams: List[OBPQueryParam])
|
||||
case class bulkDeleteMetrics()
|
||||
|
||||
@ -55,7 +55,7 @@ object ElasticsearchMetrics extends APIMetrics {
|
||||
MappedMetric.findAll(optionalParams: _*)
|
||||
}
|
||||
|
||||
override def getAllAggregateMetricsFuture(queryParams: List[OBPQueryParam], apiVersion: ApiVersion): Future[Box[List[AggregateMetrics]]] = ???
|
||||
override def getAllAggregateMetricsFuture(queryParams: List[OBPQueryParam], isNewVersion: Boolean): Future[Box[List[AggregateMetrics]]] = ???
|
||||
|
||||
override def getTopApisFuture(queryParams: List[OBPQueryParam]): Future[Box[List[TopApi]]] = ???
|
||||
|
||||
|
||||
@ -264,7 +264,7 @@ object MappedMetrics extends APIMetrics with MdcLoggable{
|
||||
}
|
||||
|
||||
// TODO Cache this as long as fromDate and toDate are in the past (before now)
|
||||
def getAllAggregateMetricsBox(queryParams: List[OBPQueryParam], apiVersion: ApiVersion): Box[List[AggregateMetrics]] = {
|
||||
def getAllAggregateMetricsBox(queryParams: List[OBPQueryParam], isNewVersion: Boolean): Box[List[AggregateMetrics]] = {
|
||||
/**
|
||||
* Please note that "var cacheKey = (randomUUID().toString, randomUUID().toString, randomUUID().toString)"
|
||||
* is just a temporary value field with UUID values in order to prevent any ambiguity.
|
||||
@ -309,7 +309,7 @@ object MappedMetrics extends APIMetrics with MdcLoggable{
|
||||
val extendedIncludeImplementedByPartialFunctionsQueries = extendCurrentQuery(includeImplementedByPartialFunctionsNumberList)
|
||||
|
||||
val result = scalikeDB readOnly { implicit session =>
|
||||
val sqlQuery = if(apiVersion.equals(ApiVersion.v5_1_0))
|
||||
val sqlQuery = if(isNewVersion) // in the version, we use includeXxx instead of excludeXxx, the performance should be better.
|
||||
sql"""SELECT count(*), avg(duration), min(duration), max(duration)
|
||||
FROM metric
|
||||
WHERE date_c >= ${new Timestamp(fromDate.get.getTime)}
|
||||
@ -362,8 +362,8 @@ object MappedMetrics extends APIMetrics with MdcLoggable{
|
||||
}}
|
||||
}
|
||||
|
||||
override def getAllAggregateMetricsFuture(queryParams: List[OBPQueryParam], apiVersion: ApiVersion): Future[Box[List[AggregateMetrics]]] = Future{
|
||||
getAllAggregateMetricsBox(queryParams: List[OBPQueryParam],apiVersion)
|
||||
override def getAllAggregateMetricsFuture(queryParams: List[OBPQueryParam], isNewVersion: Boolean): Future[Box[List[AggregateMetrics]]] = Future{
|
||||
getAllAggregateMetricsBox(queryParams: List[OBPQueryParam], isNewVersion)
|
||||
}
|
||||
|
||||
override def bulkDeleteMetrics(): Boolean = {
|
||||
|
||||
@ -37,9 +37,9 @@ object RemotedataMetrics extends ObpActorInit with APIMetrics {
|
||||
(actor ? cc.getAllMetrics(queryParams)).mapTo[List[APIMetric]]
|
||||
)
|
||||
|
||||
override def getAllAggregateMetricsFuture(queryParams: List[OBPQueryParam], apiVersion: ApiVersion): Future[Box[List[AggregateMetrics]]] ={
|
||||
logger.debug(s"RemotedataMetrics.getAllAggregateMetrics($queryParams, $apiVersion)")
|
||||
(actor ? cc.getAllAggregateMetricsFuture(queryParams,apiVersion)).mapTo[Box[List[AggregateMetrics]]]
|
||||
override def getAllAggregateMetricsFuture(queryParams: List[OBPQueryParam], isNewVersion: Boolean): Future[Box[List[AggregateMetrics]]] ={
|
||||
logger.debug(s"RemotedataMetrics.getAllAggregateMetrics($queryParams, $isNewVersion)")
|
||||
(actor ? cc.getAllAggregateMetricsFuture(queryParams,isNewVersion)).mapTo[Box[List[AggregateMetrics]]]
|
||||
}
|
||||
|
||||
override def getTopApisFuture(queryParams: List[OBPQueryParam]): Future[Box[List[TopApi]]] = {
|
||||
|
||||
@ -40,9 +40,9 @@ class RemotedataMetricsActor extends Actor with ObpActorHelper with MdcLoggable
|
||||
logger.debug("getAllMetrics()")
|
||||
sender ! (mapper.getAllMetrics(queryParams))
|
||||
|
||||
case cc.getAllAggregateMetricsFuture(queryParams: List[OBPQueryParam], apiVersion: ApiVersion) =>
|
||||
logger.debug(s"RemotedataMetricsActor.getAllAggregateMetricsFuture($queryParams, $apiVersion)")
|
||||
sender ! (mapper.getAllAggregateMetricsBox(queryParams,apiVersion))
|
||||
case cc.getAllAggregateMetricsFuture(queryParams: List[OBPQueryParam], isNewVersion: Boolean) =>
|
||||
logger.debug(s"RemotedataMetricsActor.getAllAggregateMetricsFuture($queryParams, $isNewVersion)")
|
||||
sender ! (mapper.getAllAggregateMetricsBox(queryParams, isNewVersion))
|
||||
|
||||
case cc.getTopApisFuture(queryParams: List[OBPQueryParam]) =>
|
||||
logger.debug(s"getTopApisFuture($queryParams)")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user