From 7677d95c729ab88080d742461fcb3b07c8b421f7 Mon Sep 17 00:00:00 2001 From: jwnskanzkwk Date: Fri, 29 May 2020 17:49:46 +0100 Subject: added leaderboard to sidebar --- database.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'database.py') diff --git a/database.py b/database.py index ba2a83b..cbd3308 100755 --- a/database.py +++ b/database.py @@ -98,4 +98,17 @@ class Database: def add_date_to_permalink(self, permalink, date): self.cursor.execute("UPDATE lambdas SET created = ? WHERE permalink = ?;", (date, permalink)) - self.connection.commit() \ No newline at end of file + self.connection.commit() + + def get_lambda_leaderboard(self): + self.cursor.execute(""" + SELECT users.user_name, COUNT(lambdas.userID) AS times_helped, users.lambda + FROM lambdas INNER JOIN users ON users.userID = lambdas.userID + WHERE created > (strftime('%s','now') - (60 * 60 * 24 * 30)) + GROUP BY lambdas.userID ORDER BY times_helped DESC LIMIT 10; + """) + return self.cursor.fetchall() + +if __name__ == "__main__": + import subreddit + print(subreddit.every_day()) \ No newline at end of file -- cgit v1.2.3