0

I'm trying to design an API backend (for a mobile app) around the concept of a leaderboard.

Some of the requirements:

  • I am interested only in assigning points following the validation of certain rules
  • the backend should be multi app: app1 should have some rules, app2 can have another set of rules
  • the backend receives actions made by users on the mobile app and has to validate if those actions are valid and assign points
  • rules can be something like:

give the user 10 points if it's the first time you see action A in 24 hours

give the user 10 points if action B happens but don't give the points if you see action B more than 10 times per week

  • there has to be a log of the previous actions so it can be reported to the mobile app

  • compute points, leaderboard scores and reports (in a given time frame)

I looked into merit but I didn't understand if a model can have multiple point rules files (eg: userA belongs to appA so rulesB don't apply to him) and if there's a trail of every action or just the current score.

In brief: does merit support of all of that? If not, what do you suggest?

Community
  • 1
  • 1
rhymes
  • 314
  • 9
  • 16

1 Answers1

0

Merit doesn't support all of that out of the box, but provides enough infrastructure to solve everything with some additional code.

the backend should be multi app: app1 should have some rules, app2 can have another set of rules

Do you want the backend to be single application computing reputation for all your mobile apps? If so, namespacing routes by mobile app will solve this. For example /app1/purchased and /app2/won can map to different actions, and by following that convention you make sure that each app has it's own set of rules.

there has to be a log of the previous actions so it can be reported to the mobile app

There is a merit_activity_logs table with the trail of every action that happened. From it you can build some logic so your mobile apps display to a user its previous activity.

compute points, leaderboard scores and reports (in a given time frame)

Compute points is done out of the box, keeping the history of every change. There used to be Merit::Badge.last_granted and Merit::Score.top_scored, but I removed because it was app specific and needed too much configuration. It's probably useful for you to check how the queries looked like:


The other features you mention are supported by merit out of the box.

TuteC
  • 4,342
  • 30
  • 40