[Solved] Working in preview but not in live published site

:triumph:
What I have to say is soo much that I need a video for this
So please ladies, geniuses and gentlemen, watch this 7 min video of what my problem is :slight_smile:

here’s my code :
(lol sorry pasting the whole thing which makes it long but you (I personally) never know what the problem is)

import wixData from 'wix-data';
import wixWindow from 'wix-window';
import wixUsers from 'wix-users';
import numeral from "numeral";

let filter1Star = wixData.filter().eq("rating", 1).and(wixData.filter().eq("ratedMemberId", $w('#dynamicDataset').getCurrentItem()._id));
let filter2Star = wixData.filter().eq("rating", 2).and(wixData.filter().eq("ratedMemberId", $w('#dynamicDataset').getCurrentItem()._id));
let filter3Star = wixData.filter().eq("rating", 3).and(wixData.filter().eq("ratedMemberId", $w('#dynamicDataset').getCurrentItem()._id));
let filter4Star = wixData.filter().eq("rating", 4).and(wixData.filter().eq("ratedMemberId", $w('#dynamicDataset').getCurrentItem()._id));
let filter5Star = wixData.filter().eq("rating", 5).and(wixData.filter().eq("ratedMemberId", $w('#dynamicDataset').getCurrentItem()._id));
let filterSumAmount = wixData.filter().eq("ratedMemberId", $w('#dynamicDataset').getCurrentItem()._id);
function aboutBox() {
    $w('#aboutBox').expand()
    $w('#reviewsBox').collapse()
    $w('#coursesBox').collapse()
    $w('#postsBox').collapse()
}
function reviewsBox() {
    $w('#reviewsBox').expand()
    $w('#aboutBox').collapse()
    $w('#coursesBox').collapse()
    $w('#postsBox').collapse()
}
function coursesBox() {
    $w('#aboutBox').collapse()
    $w('#reviewsBox').collapse()
    $w('#coursesBox').expand()
    $w('#postsBox').collapse()
}
function postsBox () {
    $w('#aboutBox').collapse()
    $w('#reviewsBox').collapse()
    $w('#coursesBox').collapse()
    $w('#postsBox').expand()
}
function onestar() {
    $w('#loading').show()
    wixData.aggregate("memberratings")
        .filter(filter1Star)
        .sum("rating", "rating")
        .run()
        .then((results) => {
 let x = Number((results.items[0].rating) / 1)
            $w('#inputOneStars').value = x;
            console.log(results)
            $w('#loading').hide()
        });
}
function twostars() {
    $w('#loading').show()
    wixData.aggregate("memberratings")
        .filter(filter2Star)
        .sum("rating", "rating")
        .run()
        .then((results) => {
 let x = Number((results.items[0].rating) / 2)
            $w('#inputTwoStars').value = x;
            console.log(results)
            $w('#loading').hide()
        });
}
function threestars() {
    $w('#loading').show()
    wixData.aggregate("memberratings")
        .filter(filter3Star)
        .sum("rating", "rating")
        .run()
        .then((results) => {
 let x = Number((results.items[0].rating) / 3)
            $w('#inputThreeStars').value = x;
            console.log(results)
            $w('#loading').hide()
        });
}
function fourstars() {
    $w('#loading').show()
    wixData.aggregate("memberratings")
        .filter(filter4Star)
        .sum("rating", "rating")
        .run()
        .then((results) => {
 let x = Number((results.items[0].rating) / 4)
            $w('#inputFourStars').value = x;
            console.log(results)
            $w('#loading').hide()
        });
}
function fivestars() {
    $w('#loading').show()
    wixData.aggregate("memberratings")
        .filter(filter5Star)
        .sum("rating", "rating")
        .run()
        .then((results) => {
 let x = Number((results.items[0].rating) / 5)
            $w('#inputFiveStars').value = x;
            console.log(results)
            $w('#loading').hide()
        });
}
function sumAmount() {
    $w('#loading').show()
    wixData.aggregate("memberratings")
        .filter(filterSumAmount)
        .sum("rating", "rating")
        .run()
        .then((results) => {
            $w('#sumAmount').value = results.items[0].rating;
            console.log(results)
            $w('#loading').hide()
        });

function totalRatings() {
    $w('#loading').show()
    wixData.query("memberratings")
        .eq("ratedMemberId", $w('#dynamicDataset').getCurrentItem()._id)
        .count()
        .then((num) => {
            $w('#totalRatings').value = num;
            console.log(num)
            $w('#loading').hide()
        });
}
function starSlider() {
    $w('#loading').show()
 let total = Number($w('#totalRatings').value)
 let oneData = Number($w('#inputOneStars').value)
 let twoData = Number($w('#inputTwoStars').value)
 let threeData = Number($w('#inputThreeStars').value)
 let fourData = Number($w('#inputFourStars').value)
 let fiveData = Number($w('#inputFiveStars').value)
 let one = Number((oneData / total) * 100).toFixed(1)
 let two = Number((twoData / total) * 100).toFixed(1)
 let three = Number((threeData / total) * 100).toFixed(1)
 let four = Number((fourData / total) * 100).toFixed(1)
 let five = Number((fiveData / total) * 100).toFixed(1)
    $w("#repeaterSlider").forEachItem(($item, itemData, index) => {
 if ($item('#ratingNumber').text === "5") {
            $item('#slider1').value = Number(five)
            $item('#ratingPercent').text = Number(five) + "%"
            $w('#loading').hide()
        }
 if ($item('#ratingNumber').text === "4") {
            $item('#slider1').value = Number(four)
            $item('#ratingPercent').text = Number(four) + "%"
            $w('#loading').hide()
        }
 if ($item('#ratingNumber').text === "3") {
            $item('#slider1').value = Number(three)
            $item('#ratingPercent').text = Number(three) + "%"
            $w('#loading').hide()
        }
 if ($item('#ratingNumber').text === "2") {
            $item('#slider1').value = Number(two)
            $item('#ratingPercent').text = Number(two) + "%"
            $w('#loading').hide()
        }
 if ($item('#ratingNumber').text === "1") {
            $item('#slider1').value = Number(one)
            $item('#ratingPercent').text = Number(one) + "%"
            $w('#loading').hide()
        }
    });
    console.log(five)
    console.log(four)
    console.log(three)
    console.log(two)
    console.log(one)
}
function calculateRating() {
 let sumofAll = Number($w('#sumAmount').value)
 let totalofAll = Number($w('#totalRatings').value)
 let rating = Number(sumofAll / totalofAll).toFixed(1)
    $w('#ratingsDisplay3').rating = Number(rating)
    $w('#ratingsDisplay1').rating = Number(rating)
    $w('#rating').text = rating
    $w("#totalPeopleVoted").label = numeral(totalofAll).format('0,0')
    console.log(rating)
    console.log("👤 " + numeral(totalofAll).format('0,0') + " total")
}
function filterOneStar() {
    $w('#loading').show()
    $w('#dataset1').setFilter(
        wixData.filter()
        .eq("ratedMemberId", $w('#dynamicDataset').getCurrentItem()._id)
        .and(
            wixData.filter()
            .eq("rating", 1)
        )
    ).then(() => {
        $w('#removeFilterButton').expand()
        $w('#loading').hide()
 let totalCount = $w("#dataset1").getTotalCount();
 if (totalCount.toString() < "1") {
            $w('#noRatingsToShowBox').expand()
        } else {
            $w('#noRatingsToShowBox').collapse()
        }
    });
}
function filterTwoStar() {
    $w('#loading').show()
    $w('#dataset1').setFilter(
        wixData.filter()
        .eq("ratedMemberId", $w('#dynamicDataset').getCurrentItem()._id)
        .and(
            wixData.filter()
            .eq("rating", 2)
        )
    ).then(() => {
        $w('#removeFilterButton').expand()
        $w('#loading').hide()
 let totalCount = $w("#dataset1").getTotalCount();
 if (totalCount.toString() < "1") {
            $w('#noRatingsToShowBox').expand()
        } else {
            $w('#noRatingsToShowBox').collapse()
        }
    });
}
function filterThreeStar() {
    $w('#loading').show()
    $w('#dataset1').setFilter(
        wixData.filter()
        .eq("ratedMemberId", $w('#dynamicDataset').getCurrentItem()._id)
        .and(
            wixData.filter()
            .eq("rating", 3)
        )
    ).then(() => {
        $w('#removeFilterButton').expand()
        $w('#loading').hide()
 let totalCount = $w("#dataset1").getTotalCount();
 if (totalCount.toString() < "1") {
            $w('#noRatingsToShowBox').expand()
        } else {
            $w('#noRatingsToShowBox').collapse()
        }
    });
}
function filterFourStar() {
    $w('#loading').show()
    $w('#dataset1').setFilter(
        wixData.filter()
        .eq("ratedMemberId", $w('#dynamicDataset').getCurrentItem()._id)
        .and(
            wixData.filter()
            .eq("rating", 4)
        )
    ).then(() => {
        $w('#removeFilterButton').expand()
        $w('#loading').hide()
 let totalCount = $w("#dataset1").getTotalCount();
 if (totalCount.toString() < "1") {
            $w('#noRatingsToShowBox').expand()
        } else {
            $w('#noRatingsToShowBox').collapse()
        }
    });
}
function filterFiveStar() {
    $w('#loading').show()
    $w('#dataset1').setFilter(wixData.filter()
        .eq("ratedMemberId", $w('#dynamicDataset').getCurrentItem()._id)
        .and(
            wixData.filter()
            .eq("rating", 5)
        )
    ).then(() => {
        $w('#removeFilterButton').expand()
        $w('#loading').hide()
 let totalCount = $w("#dataset1").getTotalCount();
 if (totalCount.toString() < "1") {
            $w('#noRatingsToShowBox').expand()
        } else {
            $w('#noRatingsToShowBox').collapse()
        }
    });
}
export function dynamicDataset_ready() {
 // This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
 // Add your code for this event here: 
    onestar()
    twostars()
    threestars()
    fourstars()
    fivestars()
    sumAmount()
    totalRatings()
    setTimeout(() => {
        starSlider()
        calculateRating()
    }, 5000)
}
export function showRatingValues_click(event) {
 // This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
 // Add your code for this event here: 
    $w('#ratingValueBox').expand()
    $w('#showRatingValues').hide('fade')
    $w('#showRatingValuesInverse').show('fade')
}

export function showRatingValuesInverse_click(event) {
 // This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
 // Add your code for this event here: 
    $w('#ratingValueBox').collapse()
    $w('#showRatingValues').show('fade')
    $w('#showRatingValuesInverse').hide('fade')
}
export function navigstionButton_click(event) {
 // This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
 // Add your code for this event here: 
 let $item = $w.at(event.context)
 let label = $item('#navigstionButton').label
    $w('#navigationRepeater').forEachItem(($item1, itemData, index) => {
 if ($item1('#navigstionButton').label === label) {
            $item1('#onPageBox').show()
        } else {
            $item1('#onPageBox').hide()
        }
    })
    $w('#navigationRepeater').forEachItem(($item1, itemData, index) => {
 if (label === "About") {
            aboutBox()
        }
 if (label === "Reviews")  {
            reviewsBox()
        }
 if (label === "Posts") {
            postsBox()
        }
 if (label === "Courses")  {
            coursesBox()()
        }
    })
}
export function ratingNumber_click(event) {
 // This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
 // Add your code for this event here: 
 let $item = $w.at(event.context)
 let rating = $item('#ratingNumber').text
    $w("#repeaterSlider").forEachItem(($item1, itemData, index) => {
 if (rating === "5") {
            filterFiveStar()
        }
 if (rating === "4") {
            filterFourStar()
        }
 if (rating === "3") {
            filterThreeStar()
        }
 if (rating === "2") {
            filterTwoStar()
        }
 if (rating === "1") {
            filterOneStar()
        }
    });
}
export function totalPeopleVoted_click(event) {
 // This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
 // Add your code for this event here: 
    filterFiveStar()
}
export function removeFilterButton_click(event) {
 // This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
 // Add your code for this event here: 
    $w('#loading').show()
    $w('#dataset1').setFilter(
        wixData.filter()
    ).then(() => {
        $w('#removeFilterButton').collapse()
        $w('#dataset1').refresh()
        $w('#loading').hide()
 let totalCount = $w("#dataset1").getTotalCount();
 if (totalCount.toString() < "1") {
            $w('#noRatingsToShowBox').expand()
        } else {
            $w('#noRatingsToShowBox').collapse()
        }
    });
}
export function ratingNumber_dblClick(event) {
 // This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
 // Add your code for this event here: 
    ratingNumber_click()
}

link to the website - https://okeyiwobi6.wixsite.com/my-site/members/dj-bon26
might update my url soon. But anytime I update it I’ll update this post unless it becomes locked

Man someone gotta tell me wassup looked like a gitch to meee

DJ bon26

Hi,
Have you logged in with your admin mail id When you test with Publish Site ?


See the Screenshot am Receiving Error Regards , Wix-Users Only.

Even though am Unable to Login or Sign up.

  1. Why dont you use Wix’s Default Login ?

Or try This

I’ll try wix default loginn thankss for replyingg

lol I’ve been there nd that wasn’t my issue, you know with the permissions thing but thanks thoo

Okay I’m back and uhhhh haha nope still the same :frowning: I’ll try unpublishing and republishing because fr it gotta be a daym glitch

I looked at your site and have a few observations:

The following lines of code are in the wrong place. What happens is that they end up executing before the dataset is ready, and therefore return empty results.

let filter1Star = wixData.filter().eq("rating", 1).and(wixData.filter().eq("ratedMemberId", $w('#dynamicDataset').getCurrentItem()._id));
let filter2Star = wixData.filter().eq("rating", 2).and(wixData.filter().eq("ratedMemberId", $w('#dynamicDataset').getCurrentItem()._id));
let filter3Star = wixData.filter().eq("rating", 3).and(wixData.filter().eq("ratedMemberId", $w('#dynamicDataset').getCurrentItem()._id));
let filter4Star = wixData.filter().eq("rating", 4).and(wixData.filter().eq("ratedMemberId", $w('#dynamicDataset').getCurrentItem()._id));
let filter5Star = wixData.filter().eq("rating", 5).and(wixData.filter().eq("ratedMemberId", $w('#dynamicDataset').getCurrentItem()._id));
let filterSumAmount = wixData.filter().eq("ratedMemberId", $w('#dynamicDataset').getCurrentItem()._id);

You need to move these lines of code to run inside of a dataset onReady() function, which is in the page’s onReady(). Something like this:

$w.onReady(function () {
    $w("#dynamicDataset").onReady(() => {
       // the dataset is now ready
       // ==> your code goes here <==
    });
});

See the dataset onReady() API for how and why this is needed.
For more information on the page onReady(), see the following:

  • page onReady() API

  • $w.onReady() :: a guide for the perplexed

You also have a code syntax error which will cause errors in code execution.


I think all you need to do is get rid of the extra parentheses:

courseBox()

Also, please do not post IN ALL CAPS.

YES SIR
lol

yea I changed it

THANK YOU MAN it works noww

All I have to do is figure out why the filter is returning zero but that’s for me to handle

An error is better than a glitch

DJ bon26