Golden 'Visits'-medal




Quite odd indeed. Maybe a tiny hickup somewhere? (Or could be a “if a = b” instead of “if a >= b”? Guess not)

Cheers @flabbyrabbit!

If anything, it has to be what @DOSmaster said… >_>

Naaah. <.< Not true, I make mistakes, sometimes, oke a few times, oke a lot. But so does everyone. :P


Thats what i found on GitHub
hackthis.co.uk/blob/master/files/class.user.php (165)
if ($this->consecutive == 7) {
$this->awardMedal('visits');
} else if ($this->consecutive == 14) {
$this->awardMedal('visits', 2);
} else if ($this->consecutive == 30) {
$this->awardMedal('visits', 3);
}
Rewrite to
if ($this->consecutive >= 7) {
$this->awardMedal('visits');
} else if ($this->consecutive >= 14) {
$this->awardMedal('visits', 2);
} else if ($this->consecutive >= 30) {
$this->awardMedal('visits', 3);
}
Or better
if (($this->consecutive >= 7) and (not have "visits 1" medal))) {
$this->awardMedal('visits');
} else if (($this->consecutive >= 14) and (not have "visits 2" medal)) {
$this->awardMedal('visits', 2);
} else if (($this->consecutive >= 30) and (not have "visits 3" medal)) {
$this->awardMedal('visits', 3);
}
P.S. How to get “Contributor” medal? :)

Why waste a look up when you know the only day you could possibly award this is on their 30th consecutive visit? Seeing as it has to be consecutive there has to be a 30th visit - it can’t jump from 29 to 31. Obviously something screwed up but I don’t think it is that (I am happy to be proved wrong :p)

@PNTSTR Make a PR that gets accepted. :P
@flabbyrabbit Something must indeed have gone wrong, maybe the server was chasing a bunny and didn’t feel like stopping to check it?
Code seems fine to me to be honest, maybe a “just to be sure”
else if ($this->consecutive >= 30)

I’m still looking for the cause, but noticed that Coen’s 30 day was on New Year day. What if code:
SELECT DATEDIFF(last_active, CURDATE())
return not that that we expect?
And code in class.stats.php (25) shoud rewrite from
if ($res->diff == -1)
$consecutive = 1;
to:
if ($res->diff <= -1)
$consecutive = 1;

Then we debug it (Echo replies to an overlay) by setting fake dates and run it on a private server. :P

Seeing as the consecutive login counter continued to function correctly it looks like the DATEDIFF did it’s job - the only paths in that part of the code are to reset the counter to 1 or increment. Good idea though.

Or maybe the database had a derp when running this:
public function awardMedal($label, $colour=1, $uid=null) {
if (!$uid)
$uid = $this->uid;
$st = $this->app->db->prepare('INSERT IGNORE INTO users_medals (`user_id`, `medal_id`) SELECT :uid, medal_id FROM medals WHERE label = :label AND colour_id = :colour');
$result = $st->execute(array(':label' => $label, ':colour' => $colour, ':uid' => $uid));
if ($st->rowCount()) {
if ($uid == $this->uid) {
// Add to feed
$this->app->feed->call($this->username, 'medal', $label, $colour);
} else {
// Lookup username
$st = $this->app->db->prepare('SELECT username FROM users WHERE user_id = :uid');
$st->execute(array(':uid' => $uid));
$result = $st->fetch();
$this->app->feed->call($result->username, 'medal', $label, $colour);
}
}
return (bool) $result;
}


A beginner practices until he gets it right, a professional practices until he can’t get it wrong!

Since gold medal are 150 pts, platinum would be 200 ?
Idea for platinum medals ;
- Login everyday for a year
- Post 2000 message
- Earn 10k score
What you guys think about it ?
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘\’‘ at line 1


However, that’s a great name for the medals ! :)
And yeah it’s a bit extreme but platinum medals are just for extreme Hackthis’s peoples :)
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘\’‘ at line 1

@Mugiwara27 / @dloser I think you’re right. I would like to bring this to a wider context. The medals (in general: trophies, gamification) are meant to give people incentive for being an active member of the community, solving the challenges etc. I make a guess here, since I was not involved in the creation of this site.
Introducing new medals could be a good idea in general. Of course as soon as new challenges are developed, they could yield new medals; uptil then it may be a good idea to introduce more medals for social aspects of the website. Bringing in a platinum trophy is a cool idea, although not many would reach that level. Thinking of other medals in the medium-range would reach a broader public and may motivate more people to become active participants in the community

The more points you can get with some special medals, the more peoples in Hackthis are going to be encouraged ( or challenged ) to earn this medal
But yeah, introducing new medium-range medal could be a good idea too
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘\’‘ at line 1


what about some medals you can get when you have
- unlocked all the bronze medals
- unlocked all the silver medals
- unlocked all the gold medals
- master medal - unlocked all of the above
WaRWolFz crew