201
Views
12
Comments
Solved
OSMDb Reactive Movie App

Hi Everyone 

I was making the OSMDb movie Application , I have a question in the average ratings part 

Now I have only one admin Many Jane , I have created  2 more admins abc and xyz . Now when I am adding ratings for mary jane  ( for example - 4 stars ) the 4 stars are being reflected as Average ratings for all the other admins  . Once  I am logging as abc ( for example I gave 3 stars for the same movie to which mary jane has given 4 stars ) I am seeing average ratings as 4 stars only . Same goes with xyz also the average ratings are being given as 4 stars only. 

From my knowledge the Average Ratings = Sum of all the ratings given by different admins divided by Total number of admins .

I have 3 different admins . How can I achieve the average ratings as above 

Do help 

Regards 

Priya

2023-03-03 06-59-12
Reemali patil
Solution

Hi Priya,

To achieve the desired behavior for calculating average ratings in your OSMDb movie application, you need to ensure that each admin's ratings are considered separately when calculating the average 

I attached a oml file , Take the reference from it to achieve

Regards

Reemali

OSMDb.oml
UserImage.jpg
Priya Kumari

Hi Reemali 

I checked your oml I was not able to download the core module , it will be very help if you provide another oml 

2023-03-03 06-59-12
Reemali patil

yeah sure,

I am attaching core module oml as well.

Regards

OSMDb_core.oml
UserImage.jpg
Priya Kumari

 Hi @Reemali patil 

I checked your omls .. 

How and where did you calculated the average ratings ? Is there any mathematical calculation you did for it ?

Regards 

Priya Kumari 

2023-03-03 06-59-12
Reemali patil

Hi ,

Just check  GetAverageRating Aggregate in MovieDetail Screen , in that aggregate i have made a calculated attribute of average.

Regards

UserImage.jpg
Priya Kumari

Hi @Reemali patil 

I made exactly as you explained but still I am not able to fetch the average value and now when I am adding the Ratings in "Your Ratings " it is not giving the ratings immediately , when I am reloading the page then only I am getting the ratings . In Average ratings part the ratings given by first admin is being carried as average ratings for other admins .  I am attaching the oml if you and check and tell me .

OSMDb_PK.oml
2023-10-21 19-42-11
Tousif Khan
Champion
Solution

Hi @Priya Kumari 

I have fixed your issue, the only thing is, your mapping was not correct on the average rating block, you don't need any event handler there, just bind it with aggregate that returns the average rating 

Also there are some CSS issues as well - working fine now please check, 

I hope now your issue will be resolved.

Thanks

Tousif Khan

OSMDb_PK_2.1 Updated.oap
UserImage.jpg
Priya Kumari

Hi @Tousif Khan 

Sorry , I did not found the answer to it . In the guided path it had only one role mary jane , The ratings provided by the admin was also considered as the average ratings . But I created 2 more admins . The average movie ratings for a particular movie should be calculated as the ratings given by all the admins divided by total number of admins .

But here , The average ratings is the ratings given by the first admin mary jane and it is being reflected as average ratings for all the other admins as well. I think this is not correct . 

2023-10-21 19-42-11
Tousif Khan
Champion

Hi @Priya
Lets suppose I am the first person who give the rating 5, so for the the movie has only one rating which is given by first person, so if any other user login to the app he will see the average rating as 5.

Now if he gives some rating suppose 3, then the average will be calculated as

avg = 5+3/2

avg rating will become 4 in this case.
Check the updated file
URL - https://personal-ejuytnht.outsystemscloud.com/OSMDb_PK/

I hope you understand.
Thanks

OSMDb_PK_Updated 2.3.oap
2023-10-21 19-42-11
Tousif Khan
Champion
Solution

Hi @Priya Kumari 

I have fixed your issue, the only thing is, your mapping was not correct on the average rating block, you don't need any event handler there, just bind it with aggregate that returns the average rating 

Also there are some CSS issues as well - working fine now please check, 

I hope now your issue will be resolved.

Thanks

Tousif Khan

OSMDb_PK_2.1 Updated.oap
2023-06-07 04-47-12
Ayush Tyagi

Hello , 

As per my knowledge to achieve the average ratings calculation based on individual admins' ratings, you need to consider the following steps:

1. Database Structure: Ensure that your database structure ensures storing the ratings and with them the respective admins. You should have a separate entity to store the ratings, with a foreign key referencing the admin who provided the rating.

2. Admin Rating Input: When an admin (e.g., Mary Jane, abc, xyz) provides a rating for a movie, make sure you store the admin's identity along with the rating in the database. This way, each rating will be associated with the respected admin who provided it.

3. Average Ratings Calculation: Instead of calculating the average based on all the admins(Sum of all the ratings given by different admins divided by Total number of admins ), calculate the average ratings separately for each admin. Below I have given an example of how you can calculate the average ratings for a particular admin:

a. Fetch all the ratings provided by that admin from the database.

b. Calculate the sum of those ratings.

c. Divide the sum by the total count of ratings given by that particular admin.

4. Displaying Average Ratings: Display the average ratings specific to each admin separately. When logged in as Mary Jane, show the average rating calculated based on the ratings provided by Mary Jane only. same goes for abc and xyz, show the average ratings calculated based on their ratings given by them.

By following above steps, you can calculate and display the average ratings specific to each admin. This approach will make sure that the average ratings are calculated based on the ratings given by individual admins and not the total ratings provided by all admins combined.

I hope this helps.

UserImage.jpg
Priya Kumari

Hi @Ayush Tyagi 

I want to ask few things 

1) Database Structure - I have a foreign key with related with user and Ratings 

2) Admin Rating Input -  When an admin (e.g., Mary Jane, abc, xyz) provides a rating for a movie, make sure you store the admin's identity along with the rating in the database  

How can I achieve this ?

3) Average Ratings Calculation -

a. Fetch all the ratings provided by that admin from the database 

For that - 

One admin can give one ratings for one particular movie . 

Different ratings can be achieved by different admins  regarding one movie 

and the sum of all the ratings given by different admins divided by total number of admins gives the average ratings . 

I need to achieve this 

It will be helpful if you can help me in this 

Regards 

Priya Kumari

2023-03-03 06-59-12
Reemali patil
Solution

Hi Priya,

To achieve the desired behavior for calculating average ratings in your OSMDb movie application, you need to ensure that each admin's ratings are considered separately when calculating the average 

I attached a oml file , Take the reference from it to achieve

Regards

Reemali

OSMDb.oml
UserImage.jpg
Priya Kumari

Hi Reemali 

I checked your oml I was not able to download the core module , it will be very help if you provide another oml 

2023-03-03 06-59-12
Reemali patil

yeah sure,

I am attaching core module oml as well.

Regards

OSMDb_core.oml
UserImage.jpg
Priya Kumari

 Hi @Reemali patil 

I checked your omls .. 

How and where did you calculated the average ratings ? Is there any mathematical calculation you did for it ?

Regards 

Priya Kumari 

2023-03-03 06-59-12
Reemali patil

Hi ,

Just check  GetAverageRating Aggregate in MovieDetail Screen , in that aggregate i have made a calculated attribute of average.

Regards

UserImage.jpg
Priya Kumari

Hi @Reemali patil 

I made exactly as you explained but still I am not able to fetch the average value and now when I am adding the Ratings in "Your Ratings " it is not giving the ratings immediately , when I am reloading the page then only I am getting the ratings . In Average ratings part the ratings given by first admin is being carried as average ratings for other admins .  I am attaching the oml if you and check and tell me .

OSMDb_PK.oml
2023-10-21 19-42-11
Tousif Khan
Champion
Solution

Hi @Priya Kumari 

I have fixed your issue, the only thing is, your mapping was not correct on the average rating block, you don't need any event handler there, just bind it with aggregate that returns the average rating 

Also there are some CSS issues as well - working fine now please check, 

I hope now your issue will be resolved.

Thanks

Tousif Khan

OSMDb_PK_2.1 Updated.oap
UserImage.jpg
Priya Kumari

Hi @Tousif Khan 

Sorry , I did not found the answer to it . In the guided path it had only one role mary jane , The ratings provided by the admin was also considered as the average ratings . But I created 2 more admins . The average movie ratings for a particular movie should be calculated as the ratings given by all the admins divided by total number of admins .

But here , The average ratings is the ratings given by the first admin mary jane and it is being reflected as average ratings for all the other admins as well. I think this is not correct . 

2023-10-21 19-42-11
Tousif Khan
Champion

Hi @Priya
Lets suppose I am the first person who give the rating 5, so for the the movie has only one rating which is given by first person, so if any other user login to the app he will see the average rating as 5.

Now if he gives some rating suppose 3, then the average will be calculated as

avg = 5+3/2

avg rating will become 4 in this case.
Check the updated file
URL - https://personal-ejuytnht.outsystemscloud.com/OSMDb_PK/

I hope you understand.
Thanks

OSMDb_PK_Updated 2.3.oap
2022-07-11 07-49-33
Alka Asnani

Hi Priya Kumari

To calculate average rating select the Rating column in the Aggregate and choose the Average option. (as shown in image)

Then Open the MovieDetail Screen ,select the Block and change the Rating Input Parameter value to GetAverageRating.List.Current.RatingAvg.

The Aggregate fetched the average rating at the time. With the new rating, we need to make sure the average is recalculated, so that the Block displays the correct number of stars. So, for that Refresh the data in star clicked handler flow. This way, when the Event is triggered, the rating is saved in the database and the average rating is calculated again. 

Let me know if more help needed.

Thanks

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.