Filter my repeating group of type review by author such that each review shown must have a unique author?

Hi,

I have a specific use case I’m trying to implement which is essentially displaying a list of book reviews sorted by most recently created.

The catch is that I only want to show one review per reviewer. I.e. If someone comes along and writes five reviews on the website. I would like to include one of their reviews in the list of recent reviews - but not all five.

Is there a way to filter my repeating group of type review by author such that each review shown must have a unique author?

A couple of questions…

  1. How are you going to decide which review to show for each user?

  2. What’s your database structure (i.e. how do the Users and reviews relate to each other)?

Hi, thanks for responding.

  1. I’d like to just show the most recent review of each user.

  2. The user is a field on the Review

Someone else might have a better solution… but almost everything I can think of right now involves either nested searches and/or advanced filters… both of which you’d rather avoid if possible for performance reasons…

But, by far the simplest and most performant solution I can think of (and certainly what I would do if I was doing this), is simply to add a field on the User datatype to store the User’s most recent review.

Then it’s as simple as doing a search for Users: each item’s most recent review.

Maybe use a database trigger to keep the field up to date (or include the relevant steps in the create review worklfow)

And if, for some reason, you don’t want to add a field to the User datatype, you could even create a new datatype solely for the purpose - one for each User (create it when they sign up), and just have a field for User and Most Recent Review.

Ahhh that’s a pretty clever solution - the most recent review field.

I think I’ll do this.

Thank you very much

1 Like