aboutsummaryrefslogtreecommitdiffstats
path: root/database.py
diff options
context:
space:
mode:
authorjwnskanzkwk <eddie.atten@yahoo.co.uk>2020-05-29 17:49:46 +0100
committerjwnskanzkwk <eddie.atten@yahoo.co.uk>2020-05-29 17:49:46 +0100
commit7677d95c729ab88080d742461fcb3b07c8b421f7 (patch)
tree6022a7011c0e85b28124cdbf555b9bdce341217b /database.py
parenta09665a696da60481900aeef435cca48afa698fb (diff)
downloadSmallYTChannelBot-7677d95c729ab88080d742461fcb3b07c8b421f7.tar.gz
SmallYTChannelBot-7677d95c729ab88080d742461fcb3b07c8b421f7.zip
added leaderboard to sidebar
Diffstat (limited to 'database.py')
-rwxr-xr-xdatabase.py15
1 files changed, 14 insertions, 1 deletions
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