Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
1.5k views
in Q2A Core by
Just wondering what sort of badges people would like to see implemented in a badge plugin.  Here's my list, taken from stack overflow (names and values may be different, but the idea is the same):

Probably will implement:

     Citizen Patrol × 19614     First flagged post
     Civic Duty × 8616     Voted 300 or more times
     Cleanup × 7011     First rollback
     Commentator × 79823     Left 10 comments
     Copy Editor × 174     Edited 500 posts
     Critic × 46669     First down vote
     Disciplined × 2632     Deleted own post with score of 3 or higher
     Editor × 167010     First edit
     Enlightened × 25495     First to answer and accepted with at least 10 upvotes
     Enthusiast × 16503     Visited the site each day for 30 consecutive days
     Famous Question × 8670     Asked a question with 10,000 views
     Epic × 172     Earned 200 daily reputation 50 times
     Fanatic × 2941     Visited the site each day for 100 consecutive days
     Guru × 3276     Accepted answer and score of 40 or more
     Legendary × 49     Earned 200 daily reputation 150 times
     Mortarboard × 6776     Earned at least 200 reputation in a single day
     Necromancer × 16448     Answered a question more than 60 days later with score of 5 or more
     Notable Question × 59237     Asked a question with 2,500 views
     Organizer × 23511     First retag
     Popular Question × 171939     Asked a question with 1,000 views
     Populist × 825     Answer outscored an accepted answer with score of more than 10 by more than 2x
     Reversal × 75     Provided answer of +20 score to a question of -5 score
     Revival × 16424     Answered more than 30 days later as first answer scoring 2 or more
     Scholar × 174211     Asked a question and accepted an answer
     Self-Learner × 9300     Answered your own question with score of 3 or more
     Student × 227217     Asked first question with at least one up vote
     Suffrage × 6389     Used 30 votes in a day
     Supporter × 134325     First up vote
     Teacher × 161681     Answered first question with score of 1 or more
     Yearling × 56249     Active member for a year, earning at least 200 reputation

Maybe will implement:

     Autobiographer × 48982     Completed all user profile fields
     Deputy × 587     Achieved a flag weight of 500 by reviewing and flagging appropriately
     Electorate × 1012     Voted on 600 questions and 25% or more of total votes are on questions
     Generalist × 227     Provided non-wiki answers of 15 total score in 20 of top 40 tags
     Peer Pressure × 5135     Deleted own post with score of -3 or lower
     Pundit × 1321     Left 10 comments with score of 5 or more
     Strunk & White × 1335     Edited 80 posts
     Vox Populi × 810     Used the maximum 40 votes in a day

Probably won't implement:

     Announcer × 444     Shared a link to a question that was visited by 25 unique IP addresses in 3 days
     Booster × 30     Shared a link to a question that was visited by 300 unique IP addresses in 4 days
     Favorite Question × 2749     Question favorited by 25 users
     Publicist × 11     Shared a link to a question that was visited by 1000 unique IP addresses in 5 days
     Sportsmanship × 664     Up voted 100 competing answers
     Stellar Question × 349     Question favorited by 100 users
     Taxonomist × 3741     Created a tag used by 50 questions
     Tenacious × 4278     Zero score accepted answers: more than 5 and 20% of total
     Tumbleweed × 85383     Asked a question with no votes, no answers, no comments, and low views for a week
     Unsung Hero × 1290     Zero score accepted answers: more than 10 and 25% of total

2 Answers

+1 vote
by
I think it would be great to allow custom badges. I had an idea a while back for how it would work: you would input a SQL query that returned a list of users, and those users would get the badge.

For example a query could select all users with 25+ questions. To do this though would require a cron job running once an hour or something. When you run the query an hour later, any extra users also get the badge, but any users not meeting the criteria don't get the badge any more.

I'm not exactly sure what your current method is, but it would be best to avoid running loads of queries on events like every time a user posts an answer.
by
The current method is just as you say, queries every time an event is triggered.  I can't imagine waiting an hour to update the badges, but I guess that is certainly a less stressful method.  We'll have to see how the current method handles live use, I guess.
by
Well it wouldn't have to be once an hour, it could be every 10 or 15 minutes. But it does depend how you are calculating badges. For something like Enthusiast you would have to grab all dates a user posted, then loop through to check if there are 30 consecutive ones. This would take a fair bit of time I think, you can't do that on every post!

One of the limitations of Q2A at the moment is there is no proper tracking of actions - e.g. if I edit a question then someone else edits it there is no record that I edited it in between; also the time a vote was cast is not logged, nor when a user visits a page (noy when they log in or post).
by
No, I've already implemented "Enthusiast"... what you do is record a person's first visit as "oldest_consec" and "last visit", then every time the person visits, check their last visit, and if it is more than a day ago, reset "oldest consec".  If not, count the days since "oldest_consec" and if it is greater than x, award the badge.  Either way, update "last_visit" each time.

I've also added a "posts_edited" field, allowing me to implement "Copy Editor".  There is an "on edit" event that allows this.  All I had to do for most of what you say is create a table in the db to record badge-specific data.

I agree that there might be intense load with all this going on.  I'm not a server expert, so I can't say.  Maybe I can go ask on Server Fault what sort of load this would generate...
by
Yeah that is a better way to do things as long as there aren't too many queries going on. I would suggest trying to select everything you need in 1 query and write everything you need in 1 query.
+1 vote
by
Maybe it's possible to do badge something with views for example badge "Interesting question posted" - question received 20views per day or all time...
by
Implementing "Famous Question" is easy, I can do that now.  A "views per day" type badge is more difficult.  We'd need a field for each post with its views that day that was reset every day.  Doable, I suppose.
...