aboutsummaryrefslogtreecommitdiffstats
path: root/database.py
diff options
context:
space:
mode:
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