ElkArte Community

Project Support => General ElkArte discussions => Topic started by: badmonkey on December 16, 2022, 01:27:21 pm

Title: Likes accounting
Post by: badmonkey on December 16, 2022, 01:27:21 pm
Hello everyone! Hope things are well for you!

The scenario: a monthly giveaway intended to boost board traffic and participation. The winner is based on total Likes received during the competition timeframe, let's say one month. Participation in the giveaway is optional, and staff members ineligible, so not every member will count. The giveaway will be recurring monthly. Participants could be entered into a member group. 

The question: how can the winner be determined in an automated fashion either including the participants or excluding certain members, whichever is easier?
Title: Re: Likes accounting
Post by: Spuds on December 16, 2022, 05:34:48 pm
The total likes per member over a given time period would be this query, just run this query it in your myphpadmin or adminer
Code: [Select]
SELECT
lp.id_poster, lp.like_count,
COALESCE(mem.real_name, m.poster_name) AS real_name, mem.posts
FROM (
SELECT
id_poster, COUNT(id_msg) AS like_count, MAX(id_msg) AS id_msg
FROM elkarte_message_likes
WHERE id_poster != 0
AND like_timestamp BETWEEN UNIX_TIMESTAMP("2022/12/01") AND UNIX_TIMESTAMP("2022/12/31 23:59:59")
GROUP BY id_poster
ORDER BY like_count DESC
LIMIT 10
) AS lp
INNER JOIN elkarte_messages AS m ON (m.id_msg = lp.id_msg)
INNER JOIN elkarte_members AS mem ON (mem.id_member = m.id_member)
LIMIT 10
That will give the top ten for the month defined, in this case December.  That just a pure count of likes, so can be gigged :wink: e.g. two members simply post reply's and like each others messages.

You could also do a by unique likers on a topic in a given period, so if one member likes every post in a topic of another member, it would only count as one.  If you want that query let me know.
Title: Re: Likes accounting
Post by: badmonkey on December 16, 2022, 06:55:15 pm
You're a genius spuds! You should write software or something.  :cheesy: 

Thanks man!
Title: Re: Likes accounting
Post by: Steeley on December 17, 2022, 02:43:22 am
Quote from: badmonkey – Hello everyone! Hope things are well for you!

The scenario: a monthly giveaway intended to boost board traffic and participation. The winner is based on total Likes received during the competition timeframe, let's say one month. Participation in the giveaway is optional, and staff members ineligible, so not every member will count. The giveaway will be recurring monthly. Participants could be entered into a member group.

The question: how can the winner be determined in an automated fashion either including the participants or excluding certain members, whichever is easier?


Now there's an idea that can get out of hand in a hurry.. 🤸‍♀️🥳🙌🎂 🍰🎈🎉 🎁  🤣

Might consider creating a new board, and confining the contest to that board, one that can be deleted later..  😏 😜
Title: Re: Likes accounting
Post by: badmonkey on December 17, 2022, 08:32:22 am
Quote from: Steeley –
Now there's an idea that can get out of hand in a hurry..


With any luck!    :cheesy:
Title: Re: Likes accounting
Post by: badmonkey on December 22, 2022, 06:16:52 am
Here's a brief followup. @Spuds your query code worked wonderfully! Thanks again!
Title: Re: Likes accounting
Post by: Spuds on December 22, 2022, 03:01:45 pm
Awesome  :cheesy:
Title: Re: Likes accounting
Post by: badmonkey on December 22, 2022, 07:39:49 pm
Sure is! Now to launch the monthly giveaways!