# Neuer Nutzer des Monats, funktioniert das?

**URL:** https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270
**Category:** Feature
**Created:** [17. Januar 2018 um 14:28 UTC](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270 "2018-01-17T14:28:48Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![GaryFunk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/garyfunk/32/86498_2.png) [@GaryFunk](https://meta.discourse.org/u/GaryFunk)
#### Post date: [17. Januar 2018 um 14:28 UTC](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270/1 "2018-01-17T14:28:49Z")

</div>

![Screenshot_20180116-201353](https://global.discourse-cdn.com/meta/original/3X/1/2/12bfc2a66d25a98ad9487ca53169696d8dbb8752.jpg)

 ![Screenshot_20180116-201425](https://global.discourse-cdn.com/meta/original/3X/8/b/8b89a02e89d1d8509c642555a13bc05d7e06312f.jpg)

 ![Screenshot_20180116-201436](https://global.discourse-cdn.com/meta/original/3X/c/e/ce1781b667248289139d818db6d9f024d286cbc4.jpg)

 ![Screenshot_20180116-204928](https://global.discourse-cdn.com/meta/original/3X/8/3/83ae9a6bdc3b88edc7e93048a0fc920a87b19be6.jpg)

As you can see by the screenshots the “New user of the month” ran and picked two users with less liked posts.

Gary

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [18. Januar 2018 um 00:21 UTC](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270/2 "2018-01-18T00:21:37Z")

</div>

> [@GaryFunk](#):
>
> picked two users with that were the least active instead of the most active.

You have other _new_ users that are more active, as in their posts were liked by more people? Remember it is only new users that signed up in that calendar month. Those are the only eligible users for the award.

The badge won’t be awarded at all if

- you don’t have any new users in that month (of course)

- you don’t have any new users with at least a few posts that have likes in that month

---

<div class="post-metadata">

### Author: ![GaryFunk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/garyfunk/32/86498_2.png) [@GaryFunk](https://meta.discourse.org/u/GaryFunk)
#### Post date: [18. Januar 2018 um 00:43 UTC](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270/3 "2018-01-18T00:43:51Z")

</div>

> [@codinghorror](#):
>
> You have other new users that are more active, as in their posts were liked by more people?

Yes, that is correct. The only reason michael was selected is that his only three posts received likes. The other user, weather-display was only on the forum TWO days. There is no way that user is “most active.”

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [18. Januar 2018 um 00:55 UTC](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270/4 "2018-01-18T00:55:39Z")

</div>

The way the badge works is based on active validation of other users, e.g. likes.

Simply posting 100 times isn’t enough to earn the badge; you’d need to get a fair number of likes, more than other new users.

---

<div class="post-metadata">

### Author: ![GaryFunk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/garyfunk/32/86498_2.png) [@GaryFunk](https://meta.discourse.org/u/GaryFunk)
#### Post date: [18. Januar 2018 um 01:25 UTC](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270/5 "2018-01-18T01:25:47Z")

</div>

Agreed. I understand.

A user with 52 likes and 17 topics created, one topic with 12 likes didn’t get selected. That user has more likes, many more than the two that were selected.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [18. Januar 2018 um 02:09 UTC](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270/6 "2018-01-18T02:09:24Z")

</div>

And you are 100% sure this user created their account in the specified time period?

---

<div class="post-metadata">

### Author: ![GaryFunk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/garyfunk/32/86498_2.png) [@GaryFunk](https://meta.discourse.org/u/GaryFunk)
#### Post date: [18. Januar 2018 um 02:30 UTC](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270/7 "2018-01-18T02:30:00Z")

</div>

I am. I even know the flaw in the code.

User A and B join on the same day.

User A posts three times and each post gets liked by user B and an Admin.  
User A gets a total of 9 points. 9 / 3 is a score of 3.

User B posts 30 times. User A likes 20 posts. Admin likes 20 posts.  
User B gets a total of 60 points. 60 / 30 = 2.

User B clearly much more likes than user A, yet user A gets a higher score. The logic in the code is flawed.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [18. Januar 2018 um 02:34 UTC](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270/8 "2018-01-18T02:34:47Z")

</div>

Ok, if you are certain, we can pull @eviltrout over to take a quick look, as he wrote the feature.

---

<div class="post-metadata">

### Author: ![GaryFunk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/garyfunk/32/86498_2.png) [@GaryFunk](https://meta.discourse.org/u/GaryFunk)
#### Post date: [18. Januar 2018 um 03:29 UTC](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270/9 "2018-01-18T03:29:49Z")

</div>

So, is this not a bug?

And, yes, I am certain. @zogstrip and I tested it and pretty much proved it doesn’t work as per the description.

> LEFT OUTER JOIN posts AS p ON p.user\_id = u.id

Instead of counting ALL the posts, count only the posts that have one or more like.

> LEFT OUTER JOIN posts AS p ON p.user\_id = u.id AND liked\_by.id \> 1

And frankly, this still isn’t the best way to find the most active.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [18. Januar 2018 um 04:11 UTC](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270/10 "2018-01-18T04:11:07Z")

</div>

I don’t profess to understand the query logic very well, but I’m wondering if it might be better to use `badge_posts` instead of `posts`

> <https://github.com/discourse/discourse/blob/main/app/jobs/scheduled/grant_new_user_of_the_month_badges.rb>

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [18. Januar 2018 um 04:15 UTC](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270/11 "2018-01-18T04:15:09Z")

</div>

What do the results look like if we divide the score by the number of days since signup? Perhaps pow(days, 0.8) so it doesn’t have quite as big as effect

---

<div class="post-metadata">

### Author: ![GaryFunk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/garyfunk/32/86498_2.png) [@GaryFunk](https://meta.discourse.org/u/GaryFunk)
#### Post date: [18. Januar 2018 um 04:25 UTC](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270/12 "2018-01-18T04:25:33Z")

</div>

The description states:

> measured by how often their posts were liked, and by whom.

Somehow I got it in my mind this was about active users. I apologize for that. I understand it is about likes so I am thinking the score should not be divided at all.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [18. Januar 2018 um 10:52 UTC](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270/14 "2018-01-18T10:52:52Z")

</div>

I’m thinking this query might be better : just counting the ❤s received

```sql
SELECT u.id,
  SUM(CASE
      WHEN liked_by.admin THEN 3.0
      WHEN liked_by.moderator THEN 3.0
      WHEN liked_by.trust_level = 4 THEN 2.0
      WHEN liked_by.trust_level = 3 THEN 1.5
      WHEN liked_by.trust_level = 2 THEN 1.0
      WHEN liked_by.trust_level = 1 THEN 0.25
      WHEN liked_by.trust_level = 0 THEN 0.1
      ELSE 1.0
      END) AS score
FROM users AS u
INNER JOIN user_stats AS us ON u.id = us.user_id
LEFT OUTER JOIN posts AS p ON p.user_id = u.id
LEFT OUTER JOIN post_actions AS pa ON pa.post_id = p.id AND pa.post_action_type_id = #{PostActionType.types[:like]}
LEFT OUTER JOIN users AS liked_by ON liked_by.id = pa.user_id
LEFT OUTER JOIN topics AS t ON t.id = p.topic_id
WHERE u.active
  AND u.id > 0
  AND liked_by.id > 0
  AND NOT u.staged
  AND NOT u.admin
  AND NOT u.moderator
  AND t.archetype <> '#{Archetype.private_message}'
  AND u.created_at >= CURRENT_TIMESTAMP - '1 month'::INTERVAL                                                                                                    
  AND u.id NOT IN (#{current_owners.join(',')})
GROUP BY u.id
HAVING COUNT(DISTINCT p.id) > 1
   AND COUNT(DISTINCT p.topic_id) > 1
   AND COUNT(pa.id) > 1
ORDER BY score DESC 
LIMIT #{MAX_AWARDED}

```

---

<div class="post-metadata">

### Author: ![GaryFunk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/garyfunk/32/86498_2.png) [@GaryFunk](https://meta.discourse.org/u/GaryFunk)
#### Post date: [18. Januar 2018 um 11:09 UTC](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270/15 "2018-01-18T11:09:17Z")

</div>

Thank you for your help. This gives much better results. ❤

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [18. Januar 2018 um 12:31 UTC](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270/16 "2018-01-18T12:31:17Z")

</div>

Hmm, I believe there was some logic behind the way we had it – for the purposes of new user of the month badge, a person getting a single post with 30 likes shouldn’t “outscore” a person who has 5 posts with 6 likes each.

---

<div class="post-metadata">

### Author: ![GaryFunk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/garyfunk/32/86498_2.png) [@GaryFunk](https://meta.discourse.org/u/GaryFunk)
#### Post date: [18. Januar 2018 um 12:42 UTC](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270/17 "2018-01-18T12:42:30Z")

</div>

The way it’s written, if that user only posted one time it certainly out weighs the other user if the second user posted six times and got no likes on the sixth post.

One solution is to add an additional point per post where liked.

---

<div class="post-metadata">

### Author: ![GaryFunk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/garyfunk/32/86498_2.png) [@GaryFunk](https://meta.discourse.org/u/GaryFunk)
#### Post date: [18. Januar 2018 um 17:19 UTC](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270/18 "2018-01-18T17:19:28Z")

</div>

Let’s work together to get this bug fixed and put into production.

What’s the next step and what are your ideas?

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [18. Januar 2018 um 18:47 UTC](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270/19 "2018-01-18T18:47:21Z")

</div>

> [@GaryFunk](#):
>
> One solution is to add an additional point per post where liked.

I think this is worth trying. Otherwise, I don’t agree that posting 60 times and getting 40 likes is better than posting 3 times and getting 9 likes. The first user is posting way too much.

---

<div class="post-metadata">

### Author: ![GaryFunk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/garyfunk/32/86498_2.png) [@GaryFunk](https://meta.discourse.org/u/GaryFunk)
#### Post date: [18. Januar 2018 um 19:44 UTC](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270/20 "2018-01-18T19:44:39Z")

</div>

There just isn’t a “one size fits all” for this badge. @zogstrip and I went through several ideas using real data and none are 100% perfect.

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [18. Januar 2018 um 21:54 UTC](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270/21 "2018-01-18T21:54:09Z")

</div>

Idea: what about having an admin setting to disable the automatic awarding of the new user of the month badge?

If disabled, it would then become a badge that is manually awarded by staff each month. This addresses the concerns of those who will never be satisfied by the automatic calculations, or who simply want to have control over who is awarded the badge.

For the rest, it can continue to be awarded automatically based on the imperfect but largely satisfactory system.

[Next page](https://meta.discourse.org/t/new-user-of-the-month-is-it-working/78270.md?page=2)
