beamable / BeamableProduct

The beamable product suite including com.beamable, com.beamable.server, microservice base image, portal, the installer, and build scripts
Other
5 stars 0 forks source link

Leaderboard Cohort validation should allow correct stat inequalities #3675

Open allister-beamable opened 2 months ago

allister-beamable commented 2 months ago

Describe the Bug

Leaderboard Cohorts use Stats search criteria for evaluating Stats-based eligibility rules. The validation has an incorrect list of relation names. Notably it specifies "le" instead of "lte" and it fails validation if you put in the correct one ("lte"). The list of correct relation short names is: "eq", "neq", "lt", "lte", "gt", "gte", "in", "nin". There are also long names for many of these.

Since it is impossible to publish content when the validation is failing, the validation for these Stats relations needs to either be more permissive or needs to be correct about the values it allows.

Reproducing the Behavior

Steps to Reproduce

  1. Open Content Manager in a Unity project with Beamable.
  2. Create a new piece of leaderboards content.
  3. Enable Cohorts and add a cohort.
  4. Give the cohort a name and add a stat rule
  5. Try to specify "lte" or "lessthanequal" as the relation.

Expected behavior

Actual behavior

Screenshots

Screenshot 2024-09-20 at 11 02 40

Metadata

Additional context

The set of allowed relations is defined by Scala code in the ObjectStatsRepository.search method:

            case "equal" | "eq" => "$eq"
            case "notequal" | "neq" => "$ne"
            case "lessthan" | "lt" => "$lt"
            case "lessthanequal" | "lte" => "$lte"
            case "greaterthan" | "gt" => "$gt"
            case "greaterthanequal" | "gte" => "$gte"
            case "in" => "$in"
            case "notin" | "nin" => "$nin"
cdhanna commented 2 months ago

The class is MustBeComparatorString, and we just need to update the const strings so that

  1. every left-side of the above map exists.