about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKeiji, Yoshimi <walf443@gmail.com>2017-04-17 11:23:13 +0900
committerEugen <eugen@zeonfederated.com>2017-04-17 04:23:13 +0200
commit7a5086729affa01f44eda3ad72da147abb4377c5 (patch)
tree35ac763788c811168eff6c2680db77f4307c1a81
parent5e94643058e3bc07fc1eddb46d678c32de88b284 (diff)
reduce unneed query when post without attachements. (#1907)
* reduce unneed query when post without attachements.

This commit reduce following query:

```
 MediaAttachment Load (0.9ms)  SELECT "media_attachments".* FROM "media_attachments" WHERE "media_attachments"."status
_id" IS NULL AND 1=0 ORDER BY id asc
```

* fixed for more simple changes.
-rw-r--r--app/services/post_status_service.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb
index ec2b90e07..00af28edd 100644
--- a/app/services/post_status_service.rb
+++ b/app/services/post_status_service.rb
@@ -36,7 +36,7 @@ class PostStatusService < BaseService
   private
 
   def validate_media!(media_ids)
-    return if media_ids.nil? || !media_ids.is_a?(Enumerable)
+    return if media_ids.blank? || !media_ids.is_a?(Enumerable)
 
     raise Mastodon::ValidationError, I18n.t('media_attachments.validations.too_many') if media_ids.size > 4