Rates
QName: f:rates
Applied to an association to indicate that the target node contains a property with a rating value that should be used to aggregate (increment or decrement) rating statistics on the source.
This feature automatically computes rating statistics on the source node for the property indicated on the target node. The following statistics are aggregated on the source node:
{
"_statistics": {
"ratingTotalCount": <number>,
"ratingTotalValue": <number>,
"ratingAverageValue": <number>
}
}
Where:
ratingTotalCount
is the total number of aggregated ratings
ratingTotalValue
is the total rating sum
ratingAverageValue
is the average rating (value / count).
Configuration
<thead>
<tr>
<th>Property</th>
<th>Type</th>
<th>Default</th>
<th nowrap>Read-Only</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>property</td>
<td>text</td>
<td></td>
<td></td>
<td>
The name of the property on the target node that holds the value of the rating to be applied.
</td>
</tr>
</tbody>
Rates Example
Let's assume we have an article and a review. They are associated by a custom association of type custom:hasReview
. Something like:
[Article] -> [HasReview] -> [Review]
The article might look like this to start out:
{
"title": "The Brewers are looking good this year"
}
The review might look like this:
{
"title": "My opinion with no skin in the game",
"review": "Blah blah blah, snore",
"stars": 3
}
The HasReview object would have the f:rates
feature on it:
{
"_features": {
"f:rates": {
"property": "stars"
}
}
}
This tells Cloud CMS that the target node has a property on it called stars
that holds our rating information. When the Review object is saved and the association between them created, the Article will have it's statistics incremented and will then look like this:
{
"title": "The Brewers are looking good this year",
"_statistics": {
"ratingTotalCount": 1
"ratingTotalValue": 3
"ratingAverageValue": 3
}
}
As new associations are connected up, the _statistics
are computed each time. This happens naturally for all associations. The f:rates
feature lets us compute rating counts, values and average values in addition to the aggregate counting provided for any association type.
For more information on Node Statistics, please visit the Node Statistics documentation page.