Comments (5)
Does this mean that your model rated twice the same rateable model? This seems a flaw.
from rating.
Not really. I have 3 models, User, Order and Courier (Courier delivery DB structure). A User can rate a Courier based on the Order he delivered. Assuming the 5 users rate the courier with a rating of 5 for 2 users, 3 for 2 users and 1 for one user, the courier rating can't be 5/5 but rather (total weighted sum/total weights)
(5*2) + (3*2) + (1*1)/(2+2+1)=3.4
https://math.stackexchange.com/questions/1909716/average-in-a-rating-between-1-and-5
from rating.
Based on your example, it seems like the table with ratings looks like:
- 5
- 5
- 3
- 3
- 1
The sum is 17
, with total rows of 5
. The expected average is 17/5
which is equivalent to 3.4
.
This seems a bit odd. Pulling the ratings are expected to be working with the ->avg()
call.
Did you calculate the rating from the user's side? Did you call the average rating call like this?
$user->averageRating();
$user->averageRating(Courier::class);
from rating.
No I pulled the changes from Courier side. $courier->averageRating(User::class) but the value I get is the average rating from db average not the weighted average
from rating.
This issue has been automatically closed because it has not had any recent activity. 😨
from rating.
Related Issues (11)
- Replace $fillable with $guarded.
- Error trying to get avg rating
- Rating fails at checking instance of rateable model HOT 3
- typo error HOT 1
- Laravel 6 Support
- Add ability to include a comment when rating HOT 3
- Refactor unit testing & code HOT 1
- [question] Advice on best way to sort by rating HOT 2
- Timestamp is not updated.
- Error Installing rating HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rating.