Forem Creators and Builders 🌱

Discussion on: How are the credits calculated and badges awarded?

Collapse
 
djuber profile image
Daniel Uber • Edited

Since badge credit awards I think are credit transfers (from a organization sponsoring the badge, to the badge earner), credits are introduced into the system either through purchase or admin creation.

One way that credits can be create is within the admin/users controller (there is a Credits section, with an add/remove credits form). This basically creates credits in the system (for free) and awards them to a user's account.

There is also the credits controller which allows purchasing (via Stripe/credit card) credit blocks - for example dev.to/credits has a "Purchase additional credits" button. I expect this only works if you add an api key for stripe in the general settings under "Monetization" (local testing of purchase gave an error that I needed to set a stripe api key, and pointed to stripe's documentation to do this).

monetization settings

The price of credits is set under the same settings page for credits.
credits settings

Credits are useful for adding listings (the /credits/purchase page suggests "as well as upcoming products and services" but I don't know what that includes). The listings page does give prices for each category when you start to create one, the categories and their prices in credits are managed from admin (/admin/apps/listings/categories or - admin -> apps -> listings -> listing categories to navigate). I'm not aware of any other way to spend credits besides purchasing a listing or awarding them to another user.

You asked in a comment about this situation:

And regarding credits, users (the post writer) need to get 1 credit for each post engagement i.e hearts, comments, saves.

I don't know whether this is possible right now. It may be achievable with some configuration of badges, but if you're also intent on removing badges from the system, it's probably more customization than we currently offer.

If you were looking to modify the credit system to trigger updates based on reactions and article postings, you might look at the way Article.score is tracked, and add credit handling there - most of this is funneled through Articles::ScoreCalcWorker which calls Article#update_score, if you added "and award user credits based on the difference between the old score and the new score" to either the worker or the model method you might be able to achieve what you're asking. I don't think that's something planned for Forem generally, so it would be a custom patch you'd need to maintain.