Hi all,
I am working on adding REST APIs for the following operations.
1. Rate an API (add rating)
2. Get rating of an API (given the UUID of the API)
A separate table is going to be added to store for API_RATINGS like what we
had in APIM 2.1.0
where it has 1:m mapping with AM_API table.
AM_API_RATINGS
ID
API_ID
SUBSCRIBER_ID
RATING
In current implementation or in the previous version of the API there is no
implementation to get the API rating when retrieving the API in Store REST
API.
We need to get the rating of the API at the same time we do the GET_API
call when thinking of the UI perspective to display the API in Store.
So there are two options available to get the rating of the API.
*Option 1 : *
Do the *getAPIRating *call (/apis/{apiId}/rating) right after the getAPI
call.
If we do this there will be t*wo REST calls* one after the other.
But the query execution will be less expensive and less complex.
*Option 2 : *
Get the rating value of the particular API inside the same
query for get_API , add it to the API object as a property and retrieve
the rating with *getAPI* call.
This will reduce it to one REST call to the server, but in DB
level, we are doing a bit complex query
e.g. Then the getAPI query will be like this with an inner
join operation.
*select *
* a.id <http://a.id>, a.name
<http://a.name>, a.context, ..... , avg(r.rating)*
*from*
* AM_API a*
* inner join*
* AM_RATING r ON a.ID = r.api_id*
* GROUP BY a.name <http://a.name>,
a.context, ..., ,..,..,*
* WHERE a.id <http://a.id> = ? ;*
* Option 3 : *
To reduce the complexity of the query described in option 2, we
can do execute two queries on the database.
- First one to get the API from the AM_API table
- Second query to get the average rating of that particular API.
Then after adding the rating value as a property of the API object
and retrieve with the *getAPI* call.
>From these two options what is the best way to implement ?
Assume if we select option 3, then, should we still have option 1 to be
used independently ?
Appreciate your feedback on this.
Thanks
Chamalee
--
Thanks & Regards,
*Chamalee De Silva*
Software Engineer
*WS**O2* Inc. :http://wso2.com/
Office :- *+94 11 2145345 <%2B94%2011%202145345>*
mobile :- *+94 7 <%2B94%2077%202782039>1 4315942*
--
Thanks & Regards,
*Chamalee De Silva*
Software Engineer
*WS**O2* Inc. :http://wso2.com/
Office :- *+94 11 2145345 <%2B94%2011%202145345>*
mobile :- *+94 7 <%2B94%2077%202782039>1 4315942*
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture