how can i display ratings within a repeater with code?

hi, i’m looking to show different ratings within a repeater for different company profiles, the repeater is linked to one database called member profiles via dataset, the ratings in which they receive are on a different dynamic web page on the site which are then linked to a ratings database, the problem is they don’t appear with a ratings db dataset linked to the repeater, so im guessing this must all be done with code? i’ve been trying to fix it for the past year :confused:

Hello Stevo,
i tried to understand your problem, but after reading your question several times still not sure what you want :grin:

You have a DB called “member profiles” which ist connected by a dataset with a repeater on site-A.
The input comes from site-B.

So what is exactly the problem ?
On site-A you have a read-only-dataset which is connected with your repeater and shows all the ratings from “member profiles”.

And on site-B you have a write-only-dataset which saves all the ratings from site-B into the database.

The only way you can connect siteA with site-B is your database.
Site-A ----> OUTPUT
Site-B —> INPUT
It should be able to do all this without any code, on my opinion.
But well i do not know your project, perhaps there are more difficulties, which i do not know at this moment.

hi russian dima, thanks for your reply, the ratings for each company profile get submitted to database B via code, the repeater on another page is connected to database A with the company profiles listed in with a dataset, it wont allow me to use two datasets to fetch a review for the ratings Db (Database B) and also fetch the company profile data from (database A)

Ok, one question.
And it is not possible to store all data in just one database?

i followed a tutorial on here which shows to have two separate db’s for the ratings system, also if the ratings were in the same db they would be inputting half blank rows into the db when a review gets submitted

Do you have the link to this tutorial?
I can not see what you see in front of you. :grin:

I do know anything about your project.
I do not know which rating-system you use and how it is structured.

All i know for now is the following…

you have 2-DBs where you puts in separately your company-profiles (DB-A)
and the second one (DB-B), where you put in companies-ratings for each company. Right?

Then you have ratings-form which is connected via dataset with DB-B and a repeater which is connected via dataset with DB-A, right?

Ok, now the question!
How do you recognize which rating, result belongs to which company?
Do you search by ID, by company-name, or how do you indentify which data A belongs to data-B?

It would be better when you show a part of your sproject, especialy your DB-structure (the relevant DB-headers and first 2-5 rows of DB-data.

Difficult to imagine everything. Give my some pics.
Perhaps also a pic of your repeater and the ratings-form.

Hi buddy sorry for the delay just been a little busy

this is the tutorial i followed

https://support.wix.com/en/article/corvid-tutorial-adding-ratings-and-reviews-to-a-wix-stores-site

“you have 2-DBs where you puts in separately your company-profiles (DB-A)
and the second one (DB-B), where you put in companies-ratings for each company. Right?” <-------- this is correct

" Then you have ratings-form which is connected via dataset with DB-B and a repeater which is connected via dataset with DB-A, right? " <----- no the add review ratings form is connected via code, the repeater showing the reviews is connected to 2 databases called reviews and review-stats,

“Ok, now the question!
How do you recognize which rating, result belongs to which company?
Do you search by ID, by company-name, or how do you indentify which data A belongs to data-B?” <----- this is the tough question as its on a different page to the main reviews repeater made in the tutorial above, it needs to be connected to code the same way, but i don’t know how

this is the link to my site

https://millwards322.wixsite.com/hiretrades

on the home page click search by trader, then type in “m” another page will load and all the profiles will load, notice how none of them have got any reviews! “thats the problem i have”, then click leave a review button, this will load the main profile page with the main reviews i made with the tutorial above they’re connected to a reviews dataset, the rest of the information is connected to another MemberProfile database

overall the ratings display needs to be connected with code to a second review-stats db within the repeater forEachItem linked to the right profile _id

pics you asked for


you can see here i’ve tried to use two datasets within the repeater to pull information from two different DB’s which doesn’t work


member profile Db 1


reviews Db where comments are stored


review-stats Db2 where the ratings are calculated, this is the Db i need to fetch the ratings from via code linked to the repeater on this page https://millwards322.wixsite.com/hiretrades/search-trader-by-name

sorry if this is long winded but hope you can help thanks

Hello Stevo,
sorry, but this is a little bit to much for me. I have to study your project in the wix-editor for understanding its whole process and to be able to help you. You have already some kind of bigger project. It would take a buch of time (for me) to solve your problem.

No problem russian-dima i hope someone else with some expert programming skills can help me

bump

Hello again, perhaps i have some more infos 4 you this time…
You work with RATINGS and REPEATER right?

Look at the following 2-examples, perhaps they can help you somehow…
Ratings…
https://russian-dima.wixsite.com/meinewebsite/rating-system

Repeater…

import wixData from 'wix-data';

 var ItemLength


  $w.onReady(function () {
    wixData.query("Collection")
    .find()
    .then( (res) => {
 let Item = res.items
      ItemLength = res.items.length
 
      wixData.query("Products")
      .find()
      .then( (results) => {
 let item = results.items
 
        $w("#repeater1").onItemReady( ($item, itemData, index) => {
 for (var i = ItemLength-1; i >= 0; i=i-1) {console.log("i = " + i), console.log("index = " + index)
          console.log('--------------------')
 if (itemData.title === Item[i].title) {$item("#TXTtype1").text = results.items[(index)*5+i+0-(1*index)].type, $item("#IMGtype1").src = results.items[(index)*5+i+0-(1*index)].image, console.log("Output-Index1 = " + index)}
 if (itemData.title === Item[i].title) {$item("#TXTtype2").text = results.items[(index)*5+i+1-(1*index)].type, $item("#IMGtype2").src = results.items[(index)*5+i+1-(1*index)].image, console.log("Output-Index2 = " + index)}
 if (itemData.title === Item[i].title) {$item("#TXTtype3").text = results.items[(index)*5+i+2-(1*index)].type, $item("#IMGtype3").src = results.items[(index)*5+i+2-(1*index)].image, console.log("Output-Index3 = " + index)}
 if (itemData.title === Item[i].title) {$item("#TXTtype4").text = results.items[(index)*5+i+3-(1*index)].type, $item("#IMGtype4").src = results.items[(index)*5+i+3-(1*index)].image, console.log("Output-Index4 = " + index)}
 if (itemData.title === Item[i].title) {$item("#TXTtype5").text = results.items[(index)*5+i+4-(1*index)].type, $item("#IMGtype5").src = results.items[(index)*5+i+4-(1*index)].image, console.log("Output-Index5 = " + index)}
          console.log('--------------------')
        }
      });
    });
  });
});

https://russian-dima.wixsite.com/meinewebsite/blank-16

Here you can see how a REPEATER is filled from 2-DATABASES.
Database-1 = “Collection” —> big main picture
Database-2 = “Products” ----> 5x small pictures (product-types)

This example (if you understand it) can help you to solve your following issue…

you can see here i’ve tried to use two datasets within the repeater to pull information from two different DB’s which doesn’t work

hi buddy thanks for this, i looked at your example and it appears to only work with a input and output rating on the same page, with my system i have an input on a different dynamic profile page and an output on another within a repeater, i would like the output to be on a different page to the input if that makes sense?

also would the id’s of Db1 match up with the id’s of db2?

do you think this would work? and do you have an example snippet code for implementing this with a rating display?

Still struggling with this issue?

yes mate i haven’t tried altering the code above you suggested because i wasn’t sure if the owner id’s would match up or not? how would the code above work with a ratings display? the rating needs to have the average and numRatings etc all worked out too?

i know where it says .title twice that would be the field id of the information i want to pull?

I think i am not able to do it without seeing you project.
Your project is alreday a little bit bigger and more complex.
If you need help see into my profile.