Best way to store Badge criteria?

后端 未结 2 515
不知归路
不知归路 2020-11-29 16:54

I\'ve been thinking about how to implement the badge feature similar to SO\'s on a new website. What is the best way to store criteria for badges?

Two ideas:

2条回答
  •  时光取名叫无心
    2020-11-29 17:37

    I agree with Will on this one.

    Create "events" over the pages so every time an event happens ie. a user deletes a post, it will query the event module with the event, lets say, EVENT_USER_DELETE_POST and then you can select that event and build a query based on it. You can then decide if a badge is awarded or not.

    This will keep the two logics seperate and keep a modular design. It should be very easy to implement this way.

    The only downside is that if the event was not "captured" then a user may well have earned a badge criteria but it has not yet been rewarded. However, this should never occur. The only situation I can think of is if the database is manipulated manually.

提交回复
热议问题