DEV: Add a default query for Top 50 Largest Uploads

DEV: Add a default query for Top 50 Largest Uploads

diff --git a/lib/queries.rb b/lib/queries.rb
index d47b1fa..3657a39 100644
--- a/lib/queries.rb
+++ b/lib/queries.rb
@@ -46,6 +46,11 @@ class Queries
             "id": -8,
             "name": "User Participation Statistics",
             "description": "Detailed statistics for the most active users"
+        },
+        "largest-uploads": {
+            "id": -9,
+            "name": "Top 50 Largest Uploads",
+            "description": "sorted by file size"
         }
     }.with_indifferent_access
 
@@ -287,6 +292,20 @@ class Queries
         posts_created DESC
     SQL
 
+    queries["largest-uploads"]["sql"] = <<~SQL
+    SELECT posts.id AS post_id,
+        uploads.original_filename,
+        ROUND(uploads.filesize / 1000000.0, 2) AS size_in_mb,
+        uploads.extension,
+        uploads.created_at,
+        uploads.url
+    FROM post_uploads
+    JOIN uploads ON uploads.id = post_uploads.upload_id
+    JOIN posts ON posts.id = post_uploads.post_id
+    ORDER BY uploads.filesize DESC
+    LIMIT 50
+    SQL
+
   # convert query ids from "mostcommonlikers" to "-1", "mostmessages" to "-2" etc.
   queries.transform_keys!.with_index { |key, idx| "-#{idx + 1}" }
   queries

GitHub sha: 931bbb67