Unrated-Limited-Unlimited / ua-backend

4 stars 0 forks source link

Rating Attributes #26

Closed Veggissss closed 6 months ago

Veggissss commented 6 months ago

This merge request includes the rework of rating Labels. Label is replaced with Attributes and AttributeCategory.

Only users with admin role can add new AttributeCategories. Regular users can add Attributes to their Ratings.

Veggissss commented 6 months ago

Currently there are no explicit checks for value range. So users can send Attribute values outside of intended ranges.

A simple check like this can be added in RatingFetcher::addAttributes():

// Verify that score is within bounds
val attributeScore = attributeInput["score"] as Double
if (attributeScore < 1.0 || attributeScore > 5.0){
     error("Invalid attribute score range.")
}

But I am still unsure about the ranges, if they should be 0-1:

// Verify that score is within bounds
val attributeScore = attributeInput["score"] as Double
if (attributeScore < 0 || attributeScore > 1.0){
     error("Invalid attribute score range.")
}

Similar checks should also be added to editRating and createRating for Rating.score.

Neelzee commented 6 months ago

If we just keep the range between 0-1, we can put the problem of actual range to frontend. So if they want to have the range be 0-10they can render is as such, but we always want them to send and recieve a value in the 0-1 ranges.

sonarcloud[bot] commented 6 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud