-
Notifications
You must be signed in to change notification settings - Fork 0
Automated Test: large-image-processing #322
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,25 +139,24 @@ def self.downsize_instructions_animated(from, to, dimensions, opts={}) | |
| end | ||
|
|
||
| def self.resize(from, to, width, height, opts={}) | ||
| optimize("resize", from, to, width, height, opts) | ||
| optimize("resize", from, to, "#{width}x#{height}", opts) | ||
| end | ||
|
|
||
| def self.downsize(from, to, max_width, max_height, opts={}) | ||
| optimize("downsize", from, to, max_width, max_height, opts) | ||
| optimize("downsize", from, to, "#{max_width}x#{max_height}", opts) | ||
| end | ||
|
|
||
| def self.optimize(operation, from, to, width, height, opts={}) | ||
| dim = dimensions(width, height) | ||
| def self.downsize(from, to, dimensions, opts={}) | ||
| optimize("downsize", from, to, dimensions, opts) | ||
| end | ||
|
|
||
| def self.optimize(operation, from, to, dimensions, opts={}) | ||
| method_name = "#{operation}_instructions" | ||
| method_name += "_animated" if !!opts[:allow_animation] && from =~ /\.GIF$/i | ||
| instructions = self.send(method_name.to_sym, from, to, dim, opts) | ||
| instructions = self.send(method_name.to_sym, from, to, dimensions, opts) | ||
|
Comment on lines
141
to
+156
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, verify the file and the code at the specified lines
cat -n app/models/optimized_image.rb | sed -n '141,156p'Repository: admin-coderabbit/coderabbit-discourse-mirror Length of output: 835 🏁 Script executed: # Search for all downsize call sites in the codebase
rg -n "downsize\(" -C2 app libRepository: admin-coderabbit/coderabbit-discourse-mirror Length of output: 1427 🏁 Script executed: # Also check for OptimizedImage.downsize specifically
rg -n "OptimizedImage\.downsize\(" -C2Repository: admin-coderabbit/coderabbit-discourse-mirror Length of output: 861 🏁 Script executed: # Let me verify the resize_emoji.rb context and opts usage
cat -n app/jobs/regular/resize_emoji.rb | head -20Repository: admin-coderabbit/coderabbit-discourse-mirror Length of output: 578 🏁 Script executed: # Also check if there are any other downsize calls I might have missed
rg -n "\.downsize\(" --type rbRepository: admin-coderabbit/coderabbit-discourse-mirror Length of output: 114 🏁 Script executed: # Search for all downsize calls without type filter
rg "downsize\(" --color=neverRepository: admin-coderabbit/coderabbit-discourse-mirror Length of output: 516 Duplicate The second The To fix this, either:
🧰 Tools🪛 RuboCop (1.84.0)[warning] 149-149: Method (Lint/DuplicateMethods) 🤖 Prompt for AI Agents |
||
| convert_with(instructions, to) | ||
| end | ||
|
|
||
| def self.dimensions(width, height) | ||
| "#{width}x#{height}" | ||
| end | ||
|
|
||
| def self.convert_with(instructions, to) | ||
| `#{instructions.join(" ")} &> /dev/null` | ||
| return false if $?.exitstatus != 0 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: admin-coderabbit/coderabbit-discourse-mirror
Length of output: 8172
Use site settings for the initial download limit instead of hardcoded 10 MB.
Line 55 uses a hardcoded
10.megabyteslimit, but the rest of the codebase consistently usesSiteSetting.max_image_size_kb.kilobytesfor download size constraints (and the resize loop on lines 66-68 also respects the site setting). This creates a mismatch: ifmax_image_size_kbis lower, the initial download overshoots the limit; if higher, the download is unnecessarily capped. Use[SiteSetting.max_image_size_kb, SiteSetting.max_attachment_size_kb].max.kilobytesto align with the pattern elsewhere.🧰 Tools
🪛 RuboCop (1.84.0)
[convention] 55-55: Avoid using
rescuein its modifier form.(Style/RescueModifier)
🤖 Prompt for AI Agents