成就/徽章系统 [英] Achievements / Badges system

查看:317
本文介绍了成就/徽章系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在浏览本网站的答案,但我还是有点不确定如何在其数据库结构和实施计划的类似系统。

I have been browsing this site for the answer but I'm still a little unsure how to plan a similar system in its database structure and implementation.

在PHP和MySQL(当采取专门行动,SO案例:填完了所有个人资料栏),这将是明确表示了一定的成绩立刻赚了,虽然我知道,这样的更新和一定的时间后,分配徽章。有了这么多的用户和放大器;徽章不会这样产生性能问题。(在规模上:高数这两个用户和放大器;徽章)

In PHP and MySQL it would be clear that some achievements are earned immediately (when a specialized action is taken, in SO case: Filled out all profile fields), although I know SO updates and assigns badges after a certain amount of time. With so many users & badges wouldn't this create performance problems (in terms of scale: high number of both users & badges).

因此​​,数据库结构我认为会一些简单的:

So the database structure I assume would something as simple as:

Badges     |    Badges_User      |    User
----------------------------------------------
bd_id      |    bd_id            |  user_id
bd_name    |    user_id          |  etc
bd_desc    |    assigned(bool)   |  
           |    assigned_at      |

但正如有些人说,这将是更好的有一个渐进式的方法让谁共有1,000,000次论坛的帖子,用户不会放慢任何功能了。

But as some people have said it would be better to have an incremental style approach so a user who has 1,000,000 forum posts wont slow any function down.

这就可以在badges_user表中的另一个表徽章可能是渐进的,或只是一个进步字段上方?

Would it then be another table for badges that could be incremental or just a 'progress' field in the badges_user table above?

感谢您的阅读,并请关注所需系统的可扩展性(像这样数以千计的用户和20至40徽章)。

Thanks for reading and please focus on the scalability of the desired system (like SO thousands of users and 20 to 40 badges).

编辑:一些铁出一些混乱我有assigned_at作为一个日期/时间,对于授予徽章的标准将最好的内线prepared查询/功能放置每个徽章是不是? (更好的灵活性)

to some iron out some confusion I had assigned_at as a Date/Time, the criteria for awarding the badge would be best placed inside prepared queries/functions for each badge wouldn't it? (better flexibility)

推荐答案

我想你建议的结构(没有分配栏按评论)会工作,增加一个额外的表,说 Submissions_User,含参考user_id说明&安培;计数提交递增领域。然后,所有你需要的是一个事件侦听器按这个帖子而记错你进行设置。

I think the structure you've suggested (without the "assigned" field as per the comments) would work, with the addition of an additional table, say "Submissions_User", containing a reference to user_id & an incrementing field for counting submissions. Then all you'd need is an "event listener" as per this post and methinks you'd be set.

编辑:对于成就徽章,在每次提交(仅适用于制作过程中提交的用户),和奖励在现场的任何相关徽章运行事件侦听器。对于基于时间的徽章,我会每天晚上运行一个cron作业。通过完整的用户列表中多次循环和奖励徽章适用。

For the achievement badges, run the event listener upon each submission (only for the user making the submission of course), and award any relevant badge on the spot. For the time-based badges, I would run a CRON job each night. Loop through the complete user list once and award badges as applicable.

这篇关于成就/徽章系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆