forked from MarseyWorld/MarseyWorld
make top poster of the day get a badge
parent
7ceaf62183
commit
f8614d79cd
|
@ -27,4 +27,4 @@ def badge_grant(user, badge_id, description=None, url=None, notify=True):
|
||||||
if notify:
|
if notify:
|
||||||
send_repeatable_notification(user.id,
|
send_repeatable_notification(user.id,
|
||||||
"@AutoJanny has given you the following profile badge:\n\n" +
|
"@AutoJanny has given you the following profile badge:\n\n" +
|
||||||
f"{badge.path}\n\n**{badge.name}**\n\n{badge.badge.description}")
|
f"{badge.path}\n\n**{badge.name}**\n\n{badge.badge.description}").created_utc += 1
|
||||||
|
|
|
@ -21,6 +21,7 @@ from files.helpers.cloudflare import *
|
||||||
from files.helpers.sorting_and_time import make_age_string
|
from files.helpers.sorting_and_time import make_age_string
|
||||||
from files.helpers.can_see import *
|
from files.helpers.can_see import *
|
||||||
from files.helpers.alerts import send_notification
|
from files.helpers.alerts import send_notification
|
||||||
|
from files.helpers.useractions import *
|
||||||
from files.routes.routehelpers import get_alt_graph, get_formkey
|
from files.routes.routehelpers import get_alt_graph, get_formkey
|
||||||
from files.routes.wrappers import calc_users
|
from files.routes.wrappers import calc_users
|
||||||
from files.__main__ import app, cache
|
from files.__main__ import app, cache
|
||||||
|
@ -136,13 +137,15 @@ def poster_of_the_day_id():
|
||||||
|
|
||||||
db = db_session()
|
db = db_session()
|
||||||
|
|
||||||
uid = db.query(User.id, func.sum(Post.upvotes)).join(Post, Post.author_id == User.id).filter(
|
user = db.query(User, func.sum(Post.upvotes)).join(Post, Post.author_id == User.id).filter(
|
||||||
Post.created_utc > t,
|
Post.created_utc > t,
|
||||||
User.admin_level == 0,
|
User.admin_level == 0,
|
||||||
).group_by(User.id).order_by(func.sum(Post.upvotes).desc()).first()[0]
|
).group_by(User.id).order_by(func.sum(Post.upvotes).desc()).first()[0]
|
||||||
|
|
||||||
t = datetime.datetime.now()
|
t = datetime.datetime.now()
|
||||||
send_notification(uid, f":marseyjam: You're the top poster of the day for the day of {t.year}-{t.month}-{t.day} :marseyjam:")
|
send_notification(user.id, f":marseyjam: You're the top poster of the day for the day of {t.year}-{t.month}-{t.day} :marseyjam:")
|
||||||
|
badge_grant(badge_id=327, user=user)
|
||||||
|
uid = user.id
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
db.close()
|
db.close()
|
||||||
|
|
Loading…
Reference in New Issue